#1679

[BUG] A state file that is not UTF-8 fails the hydrate instead of starting empty

Openlxcxjxhxopened 1d ago

The tool state files are written UTF-8 with ensure_ascii=False, so a write interrupted in the middle of a multi-byte character leaves a file that is readable but not decodable. UnicodeDecodeError is a ValueError, so it does not match a handler listing (OSError, json.JSONDecodeError) - and the exception escapes the hydrate call that runs at scan start.

Reproduced on this checkout with a state file holding {"truncated": "\xff\xfe"}:

storebefore
hydrate_todos_from_diskUnicodeDecodeError escapes
hydrate_notes_from_diskUnicodeDecodeError escapes
hydrate_threat_models_from_diskUnicodeDecodeError escapes
hydrate_coverage_from_diskUnicodeDecodeError escapes
load_user_mcp_configsUnicodeDecodeError escapes

Each of those already has the "log, start empty" behaviour; only the catch list is short.

Expected: a state file that cannot be decoded is treated like one that cannot be parsed - logged, and the store starts empty - so one damaged file does not stop the run.

Activity

0

No activity yet.