Skip to content

fix(extract): fail on AST extraction errors - #2458

Closed
Baziar wants to merge 1 commit into
Graphify-Labs:v8from
Baziar:fix/2445-fail-on-ast-extraction-error
Closed

Baziar wants to merge 1 commit into
Graphify-Labs:v8from
Baziar:fix/2445-fail-on-ast-extraction-error

Conversation

@Baziar

@Baziar Baziar commented Aug 4, 2026

Copy link
Copy Markdown

Summary

  • Exit with status code 1 when AST extraction raises an exception.
  • Stop replacing failed extraction with a successful-looking empty AST result.
  • Prevent downstream processing and graph.json creation after a total AST failure.
  • Add regression coverage for the failure path.

Corpora with no code files remain unaffected because AST extraction is only attempted when code_files is non-empty.

Tests

  • 186 passed, 1 skipped
  • Ruff checks passed.
  • graphify update . completed successfully.

Fixes #2445

@graphify-labs graphify-labs Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks safe to merge — no coupling regressions and no blocking issues, checked against the code graph (not a self-assessment).

Graphify reviewed this change.

Looks safe to merge — no coupling regressions and no blocking issues, checked against the code graph (not a self-assessment).


Graphify review — findings

This PR changes the error-handling behavior in graphify extract's AST extraction path. Previously, when AST extraction raised an exception, the code caught it, logged a message, substituted an empty result, and flagged the extraction as incomplete to continue processing. Now it exits with status code 1 instead. A new test (test_extract_exits_nonzero_when_ast_extraction_raises) is added to verify that an AST extraction failure causes a nonzero exit, emits the expected stderr message, and does not write a graph.json output file. The surface area is limited to one function in graphify/cli.py and the new test in tests/test_extract_cli.py (with an added importlib import).

No blocking issues surfaced. 1 lower-confidence candidate did not survive cross-model review.

Analysis details — impact, health, verification

Impact & health

Graphify review

Impact — 248 functions depend on the 114 functions this change touches.

Health — grade A; 2 existing hotspot(s) in the area this change touches (pre-existing, not introduced here):

  • dispatch_command() — 2 callers, 110 callees (high)
  • _run_hook_guard() — 3 callers, 6 callees (medium)

Verification — 248 functions in the blast radius were not formally verified this run (proofs are advisory here).

Gate & verification

graphify gate

PASS — objectively clean (no health regressions, tests not run — proofs not run this pass (advisory)). Grounded, not self-assessed.

Advisory (not blocking):

  • verification_scope: 205 function(s) in the blast radius were not formally verified this run

safishamsi added a commit that referenced this pull request Aug 5, 2026
… preservation, extract crash recovery; bump to 0.9.33

#2411 (thanks @JensD-git): key the C# partial-class merge on assembly
(nearest ancestor .csproj/.fsproj/.vbproj) in addition to namespace and
name, so same-name partial classes in different assemblies stay distinct
while genuine partial halves within one project still merge. Fixes a
0.9.32 regression from #2332.

#2437/#2438 (thanks @aryanbonigala, builds on PR #2439): incremental
rebuilds no longer drop member-call and indirect_call edges from a
changed file into an unchanged target. Re-resolution now sees the
unchanged corpus (nodes, contains/method edges, and _callable markers,
which now persist to graph.json like _origin); edges to a genuinely
removed target are still evicted.

#2444/#2445 (thanks @Baziar, builds on PRs #2461/#2458): a
BrokenProcessPool triggers the sequential fallback instead of being
swallowed per future, a failed worker file is retried sequentially
rather than merged as empty, and a whole-pass AST failure on a fresh
build exits non-zero instead of writing a zero-node graph
(--allow-partial opts into a best-effort partial graph).

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
@safishamsi

Copy link
Copy Markdown
Member

Shipped in v0.9.33. The direction (do not let a whole-pass AST failure masquerade as an empty graph) is what landed, gated so a fresh-build failure exits non-zero while --allow-partial still opts into a best-effort partial graph (keeping the partial-continuation path). Credited in the release notes. Thanks @Baziar.

@safishamsi safishamsi closed this Aug 5, 2026
PerryLin-0420 pushed a commit to PerryLin-0420/graphify-decouple that referenced this pull request Aug 13, 2026
… preservation, extract crash recovery; bump to 0.9.33

Graphify-Labs#2411 (thanks @JensD-git): key the C# partial-class merge on assembly
(nearest ancestor .csproj/.fsproj/.vbproj) in addition to namespace and
name, so same-name partial classes in different assemblies stay distinct
while genuine partial halves within one project still merge. Fixes a
0.9.32 regression from Graphify-Labs#2332.

Graphify-Labs#2437/Graphify-Labs#2438 (thanks @aryanbonigala, builds on PR Graphify-Labs#2439): incremental
rebuilds no longer drop member-call and indirect_call edges from a
changed file into an unchanged target. Re-resolution now sees the
unchanged corpus (nodes, contains/method edges, and _callable markers,
which now persist to graph.json like _origin); edges to a genuinely
removed target are still evicted.

Graphify-Labs#2444/Graphify-Labs#2445 (thanks @Baziar, builds on PRs Graphify-Labs#2461/Graphify-Labs#2458): a
BrokenProcessPool triggers the sequential fallback instead of being
swallowed per future, a failed worker file is retried sequentially
rather than merged as empty, and a whole-pass AST failure on a fresh
build exits non-zero instead of writing a zero-node graph
(--allow-partial opts into a best-effort partial graph).

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
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.

graphify extract substitutes an empty AST result on any exception, so a total extraction failure looks like an empty corpus

2 participants