fix(storage): survive unreadable artifact files and pin utf-8 i/o#296
Merged
Conversation
`vouch pending` — and every bulk `list_*` path — crashed with a yaml ReaderError when a single proposal file held a control character: one unreadable file took down the whole listing. add a `_load_or_skip` helper that logs a warning and skips the bad file instead of aborting, applied across proposals, claims, entities, relations, evidence, sessions, sources. the control character traces back to vouch's own file i/o relying on the locale default encoding: on a non-utf-8 locale (e.g. latin-1) read_text / write_text / open mangle non-ascii into raw bytes the yaml loader rejects, and can even crash on write. pin encoding="utf-8" on all text-mode pathlib i/o under src/vouch. adds regression tests for the resilient listing.
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Plus Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What changed
makes bulk artifact listing resilient to a single unreadable file, and pins
encoding="utf-8"on every text-mode file i/o undersrc/vouch/.Why
vouch pending— and every bulklist_*path — crashed with a yamlReaderErrorwhen one proposal file held a control character: a single badfile took down the whole listing. root cause: vouch's
read_text/write_text/openrelied on the locale default encoding, so on a non-utf-8locale (e.g. latin-1) non-ascii claim text was mangled into raw bytes the yaml
loader rejects — and writes could crash outright. the fix has two layers:
skip-and-warn on an unreadable file (defense in depth) plus pin utf-8
everywhere (the actual root cause).
What might break
nothing for existing
.vouch/users on a utf-8 system. on a non-utf-8 locale,new writes are now correct utf-8; a file already corrupted by the old
locale-encoded write path is now skipped with a warning instead of crashing the
command (re-save it as utf-8 to recover it).
VEP
not a surface change — no VEP needed.
Tests
test_example_screenshotssvg-render check (unrelated, font-metricenvironmental — fails on
main/testtoo)listing still returns the good artifacts
CHANGELOG.mdupdated under## [Unreleased]→### Fixed