Skip to content

fix(graph): survive malformed extra JSON in get_all_files - #870

Closed
yzxcj797 wants to merge 1 commit into
tirth8205:stagingfrom
yzxcj797:fix/864-malformed-extra-json
Closed

yzxcj797 wants to merge 1 commit into
tirth8205:stagingfrom
yzxcj797:fix/864-malformed-extra-json

Conversation

@yzxcj797

Copy link
Copy Markdown
Contributor

Summary

Follow-up to #861 (noted while merging it, #864): a killed writer can leave extra='' in a node row. get_all_files ran json_extract(extra, '$.virtual') over every non-File row, so SQLite raised malformed JSON and crashed every caller — build, status, visualize, watch.

Two changes in the WHERE clause:

  1. Malformed rows survive: extra IS NULL OR json_valid(extra) = 0 keeps a row with empty/truncated extra in the file inventory instead of aborting the query.
  2. Truthiness, not key presence: COALESCE(json_extract(extra, '$.virtual'), 0) != 1. Previously the presence of the key alone hid a row, so extra='{"virtual": false}' was invisible to reconciliation and immortal; now only virtual: true (resolver-managed, e.g. Spring Event markers) stays out of the inventory.

Testing

  • New regression test_get_all_files_survives_malformed_extra_and_false_virtual: inserts rows with extra='', {"virtual": false}, and {"virtual": true}, then asserts the split — malformed and false-virtual paths are returned, true-virtual stays excluded. Fails against the previous query (verified by checkout mutation: OperationalError: malformed JSON), passes with the fix.
  • pytest tests/test_graph.py tests/test_incremental.py — 176 passed (2 symlink-privilege tests deselected, a pre-existing Windows-environment limitation, same as fix(incremental): reconcile reverted file content #860/fix(graph): purge orphan rows during reconciliation #861).
  • ruff check code_review_graph/graph.py tests/test_incremental.py — all checks passed.

Fixes #864

A killed writer can leave an empty extra string in a node row. json_extract then raised SQLite malformed-JSON and crashed every get_all_files caller: build, status, visualize, watch (tirth8205#864, follow-up to tirth8205#861).

Gate the extraction with json_valid and compare on truthiness via COALESCE so a false-virtual row stays visible to reconciliation instead of being immortal. Regression inserts rows with empty, false-virtual, and true-virtual extra and asserts the split.
@github-actions

Copy link
Copy Markdown

code-review-graph review

Overall risk: 0.30 (LOW) — 4 changed function(s)/class(es), 0 affected flow(s), 1 test gap(s)

Risk-scored changes

Risk Level Symbol Location Tested
0.30 low code_review_graph/graph.py::GraphStore code_review_graph/graph.py:185 yes
0.30 low code_review_graph/graph.py::GraphStore.get_all_files code_review_graph/graph.py:1187 yes
0.05 low tests/test_incremental.py::TestRenamePurgeParity tests/test_incremental.py:1764 no
0.05 low tests/test_incremental.py::TestRenamePurgeParity.test_get_all_files_survives_malformed_extra_and_false_virtual tests/test_incremental.py:1817 (test)

Test gaps

  • tests/test_incremental.py::TestRenamePurgeParity (tests/test_incremental.py:1764)

Token savings: this graph-backed report used ~40,278 fewer tokens (~98%) than reading every changed file in full (estimated, chars/4 approximation).


Powered by code-review-graph — local-first analysis; no code leaves the CI runner.

@tirth8205

Copy link
Copy Markdown
Owner

Integrated on integration/token-efficiency-hardening as a1a8daa. File reconciliation remains available when node metadata contains malformed JSON and keeps virtual=false rows purgeable, while retaining resolver-owned virtual=true nodes. The targeted graph and incremental regressions passed.

@tirth8205

Copy link
Copy Markdown
Owner

Merged into staging through the integration PR #988 (merge commit 3030ca8). Your change is carried by commit a1a8daa, which keeps you as the author (yzxcj797). It will be promoted staging → testing → main and released from there. Thank you for the contribution! Closing this PR since its content is now on staging.

@tirth8205 tirth8205 closed this Sep 15, 2026
Bakul2006 pushed a commit to Bakul2006/code-review-graph that referenced this pull request Sep 15, 2026
…in get_all_files

Port the reviewed token-efficiency implementation with targeted regression coverage.

Source-PR: tirth8205#870
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

get_all_files: malformed JSON in nodes.extra crashes reconciliation after #861

2 participants