Skip to content

fix(affected): handle "edges"-keyed graph.json in load_graph (KeyError: 'links') - #1280

Merged
safishamsi merged 1 commit into
Graphify-Labs:v8from
s22hyun:fix/affected-edges-key
Jun 12, 2026
Merged

safishamsi merged 1 commit into
Graphify-Labs:v8from
s22hyun:fix/affected-edges-key

Conversation

@s22hyun

@s22hyun s22hyun commented Jun 12, 2026

Copy link
Copy Markdown
Contributor

Summary

graphify affected fails to load graphs produced by graphify extract,
exiting with error: could not load graph: 'links'. Every other reader works.

Root cause

graphify/affected.py::load_graph calls
json_graph.node_link_graph(raw, edges="links"), but extract writes
graph.json with an "edges" key. networkx then raises KeyError: 'links',
which the surrounding except TypeError does not catch.

__main__.py already normalizes this everywhere it loads a graph:

if "links" not in raw and "edges" in raw:
    raw = dict(raw, links=raw["edges"])

affected.load_graph is the only loader missing that normalization. Same class
of bug as #1198 (benchmark KeyError: 'links').

Fix

Mirror the existing normalization in affected.load_graph before calling
node_link_graph. links-keyed graphs and older networkx fall through unchanged.

Repro

$ graphify extract . --no-cluster      # writes an "edges"-keyed graph.json
$ graphify affected "SomeSymbol" --depth 1
error: could not load graph: 'links'   # before; after: reverse-traversal output

Tests

Added test_affected_cli_loads_edges_keyed_graph — writes an "edges"-keyed
graph (as extract does) and asserts affected reverse-traverses it. The
existing _write_graph helper only ever emitted the "links" key, so this path
was untested. Fails before the fix (KeyError: 'links'), passes after.


Found this while running graphify against a ~8,200-file monorepo (52k nodes /
186k edges) — after the fix, affected correctly reverse-traverses 621 nodes
from a core DB accessor. Happy to adjust if you'd rather hoist the
normalization into a shared helper instead of mirroring it per-loader.

@safishamsi
safishamsi merged commit 0ff84d8 into Graphify-Labs:v8 Jun 12, 2026
safishamsi added a commit that referenced this pull request Jun 18, 2026
…, #1278)

label_communities logged-and-skipped any batch whose LLM response was malformed
JSON, silently losing ~100 names per failed batch on large graphs. Split the
batch at the midpoint and retry each half (smaller prompt -> smaller output),
mirroring _extract_with_adaptive_retry; the base case re-raises so the caller
skips just that batch. Removed leftover scaffolding and corrected the docstring.

Co-Authored-By: CJdev232 <[email protected]>
Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
PerryLin-0420 pushed a commit to PerryLin-0420/graphify-decouple that referenced this pull request Aug 13, 2026
…-key

fix(affected): handle "edges"-keyed graph.json in load_graph (KeyError: 'links')
PerryLin-0420 pushed a commit to PerryLin-0420/graphify-decouple that referenced this pull request Aug 13, 2026
…phify-Labs#1280, Graphify-Labs#1278)

label_communities logged-and-skipped any batch whose LLM response was malformed
JSON, silently losing ~100 names per failed batch on large graphs. Split the
batch at the midpoint and retry each half (smaller prompt -> smaller output),
mirroring _extract_with_adaptive_retry; the base case re-raises so the caller
skips just that batch. Removed leftover scaffolding and corrected the docstring.

Co-Authored-By: CJdev232 <[email protected]>
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.

2 participants