fix: harden graph JSON loading against corruption#1537
Closed
guyoron1 wants to merge 1 commit into
Closed
Conversation
Wrap unguarded json.loads() in build_merge(), load_graph(), and _read_json_file() so corrupted graph.json files produce an actionable RuntimeError instead of an unhelpful JSONDecodeError traceback. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
safishamsi
added a commit
that referenced
this pull request
Jul 1, 2026
#1537 shipped with a manual test checklist only. Add automated tests that corrupt a graph.json and assert the actionable RuntimeError at all three load paths (build_merge, affected.load_graph, diagnostics._read_json_file) plus a happy-path guard. Also record the six merged small fixes in the changelog. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Collaborator
|
Merged into |
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.
Summary
Closes #1536
Three core graph-loading paths call
json.loads()without catchingJSONDecodeErrororOSError. Corruptedgraph.jsonfiles (from incomplete writes, power loss, or manual edits) crash with unhelpful tracebacks.This PR wraps each site with
try/exceptthat raises a clearRuntimeErrorwith recovery guidance.Changes
graphify/build.py:652—build_merge(): guards the--updateincremental merge pathgraphify/affected.py:212—load_graph(): guardsgraphify prsgraph loadinggraphify/diagnostics.py:277—_read_json_file(): guardsgraphify diagnoseTest plan
graph.jsonmanually (e.g., truncate mid-file), rungraphify extract --update— should get actionable error instead of tracebackgraphify prswith corrupt graph — should get clear errorgraphify diagnosewith corrupt graph — should get clear errorgraph.jsonfiles load as before🤖 Generated with Claude Code