verify_source() catches FileNotFoundError but store.read_source_content() raises ArtifactNotFoundError (a KeyError subclass) when content is missing. The mismatch means a single source with missing content crashes the entire verification sweep.
Bug
- File:
src/vouch/verify.py:30-31
- Buggy code:
def verify_source(store: KBStore, source: Source) -> VerificationResult:
try:
body = store.read_source_content(source.id)
except FileNotFoundError: # <-- wrong exception type
return VerificationResult(source=source, stored_ok=False,
external_status="n/a", note="stored content missing")
- Correct pattern (from
storage.py:217-221):
def read_source_content(self, source_id: str) -> bytes:
p = self._source_dir(source_id) / "content"
if not p.exists():
raise ArtifactNotFoundError(f"source content {source_id}") # KeyError subclass
return p.read_bytes()
Steps to Reproduce
vouch init && vouch source add some-file.txt (registers a source)
- Manually delete
.vouch/sources/<sha256>/content
- Run
vouch source verify or vouch doctor
- Result: unhandled
ArtifactNotFoundError traceback instead of graceful "stored content missing" report
Expected Behavior
verify_source should catch ArtifactNotFoundError and return a VerificationResult with stored_ok=False, as the code clearly intended.
verify_source()catchesFileNotFoundErrorbutstore.read_source_content()raisesArtifactNotFoundError(aKeyErrorsubclass) when content is missing. The mismatch means a single source with missing content crashes the entire verification sweep.Bug
src/vouch/verify.py:30-31storage.py:217-221):Steps to Reproduce
vouch init && vouch source add some-file.txt(registers a source).vouch/sources/<sha256>/contentvouch source verifyorvouch doctorArtifactNotFoundErrortraceback instead of graceful "stored content missing" reportExpected Behavior
verify_sourceshould catchArtifactNotFoundErrorand return aVerificationResultwithstored_ok=False, as the code clearly intended.