radicle/cob/stream: skip commits that do not have a manifest

For some COBs, parent commits can be specified for actions, for
example, patches will bundle their base and head commits as parents.

When the COB stream performs the revwalk, these commits will be
included, and will not have the manifest file – resulting in an error.

Instead, this error can be matched against, and the commit is skipped
instead. The other errors should still be resurfaced, since a commit
with a manifest should be expected to load the operation correctly,
and the commit should exist in the repository when attempting to load
it.

One might argue that a valid operation with a missing manifest could
occur, but that would mean that `radicle-cob` has performed an invalid
write. This is undetectable by the stream API, and is ambiguous with
the case of non-Op commits.
This commit is contained in:
Fintan Halpenny 2025-12-24 12:54:44 +00:00
parent cf023f750d
commit b8a6e1a52f
1 changed files with 8 additions and 1 deletions

View File

@ -138,7 +138,14 @@ where
// N.b. mark this commit as seen, so that it is not walked again
self.walk.inner.hide(commit.id()).ok();
// Skip any Op that do not match the manifest
self.load(entry).transpose().or_else(|| self.next())
match self.load(entry) {
Ok(entry) => entry.map(Ok).or_else(|| self.next()),
Err(err) => match err {
// This is a parent commit that is not an Op
error::Ops::Manifest { source: _ } => self.next(),
err => Some(Err(err)),
},
}
}
// Something was wrong with the commit
Err(err) => Some(Err(error::Ops::Commit { source: err })),