You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Bug: catalog --write truncates an existing output before rejecting invalid Unicode #22
A valid-shaped resource with JSON title "broken\ud800title" passes validate() with no errors. Running catalog.py --data input.json --output existing.md --write then returns exit 1 because the rendered string cannot be encoded as UTF-8. However, Path.write_text() has already opened/truncated the output: an existing nonempty sentinel file becomes zero bytes.
Impact / priority
P1: destructive failure in a documented command. Invalid metadata should not erase a previously generated document. This is an input-validation/output-integrity defect, not a claim of remote exploitation.
Minimal reproduction
Make a temporary copy of catalog/resources.json, changing one title to the literal JSON escape \ud800 within otherwise ordinary text.
Put known nonempty content in a temporary output file.
Run python tools/catalog.py --data <temporary-json> --output <temporary-output> --write.
Observe the Unicode error, exit 1, and an empty output file.
Acceptance
Reject strings that cannot be rendered/encoded under the documented UTF-8 contract before touching output.
Render and encode successfully before replacement; use a same-directory temporary file and atomic replacement where appropriate so failed writes preserve existing output.
Add a regression asserting unchanged existing bytes after invalid Unicode, plus successful valid non-BMP Unicode output.
Preserve exit-code behavior and generated-output determinism.
Run python tools/catalog.py --write, python tools/catalog.py, the full unittest suite and documentation-link checks on the actual candidate.
Activity
fix(catalog): preserve generated output on encoding and write failures (
fix: preserve catalog output on failed generation (#36)