Repository navigation
Fix: validate_extraction crashes on non-hashable node id / edge endpoint - #1447
Closed
dschwartzi wants to merge 1 commit into
Closed
dschwartzi wants to merge 1 commit into
dschwartzi wants to merge 1 commit into
Conversation
validate_extraction() is documented to return a list of error strings ("empty
list means valid"), but raised TypeError: unhashable type: 'list' when a node
id -- or an edge source/target -- was a non-hashable value such as a list. This
occurs in practice when an LLM extraction subagent emits malformed JSON like
{"id": ["foo", "bar"], ...}. Crash sites: the node_ids set comprehension and
the `edge[...] not in node_ids` membership tests.
Because build_from_json() validates at its start, a single malformed node
aborted the entire build, losing an otherwise-complete extraction of a large
corpus. build_from_json() itself would also raise (G.add_node(<list>) and the
`not in node_set` test) if the validator were bypassed.
- validate.py: build node_ids during the node pass, adding only hashable ids;
report a non-hashable id/endpoint as an error string instead of crashing.
All existing messages and the dangling-edge checks are preserved.
- build.py: skip dict nodes with a missing/non-hashable id and edges with
non-hashable endpoints (stderr warning). Non-dict nodes are deliberately
left to raise so the multigraph diagnostic still observes shape errors.
- tests: 3 cases in test_validate.py and 2 in test_build.py.
Member
|
Merged into |
safishamsi
added a commit
that referenced
this pull request
Jun 24, 2026
The #1447 cherry-pick only touched build.py/validate.py + tests, so it shipped without a CHANGELOG note. Add it under Unreleased. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
safishamsi
added a commit
that referenced
this pull request
Jun 24, 2026
Work-memory (#1441): save-result --outcome + graphify reflect, with recency-decayed scoring, corroboration threshold, label-matched node-existence gate, contested handling, and zero-config adoption (skill reads LESSONS.md + records outcomes; git hooks auto-reflect). Fixes: Python ClassName.method() qualified-call edges (#1446); validate_extraction/build crash on non-hashable id (#1447); graphify update now prunes a symbol removed from a surviving file without --force. 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
…nt crash fix) The Graphify-Labs#1447 cherry-pick only touched build.py/validate.py + tests, so it shipped without a CHANGELOG note. Add it under Unreleased. 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
Work-memory (Graphify-Labs#1441): save-result --outcome + graphify reflect, with recency-decayed scoring, corroboration threshold, label-matched node-existence gate, contested handling, and zero-config adoption (skill reads LESSONS.md + records outcomes; git hooks auto-reflect). Fixes: Python ClassName.method() qualified-call edges (Graphify-Labs#1446); validate_extraction/build crash on non-hashable id (Graphify-Labs#1447); graphify update now prunes a symbol removed from a surviving file without --force. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
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.
Problem
validate_extraction()is documented to return a list of error strings ("empty list means valid"), but it raisesTypeError: unhashable type: 'list'when a nodeid— or an edgesource/target— is a non-hashable value such as a list. This happens in practice when an LLM extraction subagent emits malformed JSON like{"id": ["foo", "bar"], ...}.Two crash sites:
node_ids = {n["id"] for ...}— the set comprehension over node ids.edge["source"] not in node_ids/edge["target"] not in node_ids— the set-membership tests.Because
build_from_json()callsvalidate_extraction()at its start, the whole build aborts before any graph is produced — a single malformed node from a semantic pass kills an otherwise-complete extraction of a large corpus.build_from_json()itself would also raise (G.add_node(<list>), and thenot in node_setmembership test) even if the validator were bypassed.Fix
validate.py: collectnode_idsduring the node pass, adding only hashable ids; report a non-hashable id/endpoint as an error string instead of crashing. All existing error messages and the dangling-edge checks are preserved.build.py: inbuild_from_json, skip dict nodes with a missing/non-hashable id and edges with non-hashable endpoints (with a stderr warning), so a malformed entry is dropped rather than aborting the build. Non-dict nodes are deliberately left to raise as before, somultigraph_diagnosticsstill observes shape errors.Tests
tests/test_validate.pycases: non-hashable node id reported, non-hashable edge endpoint reported, and valid ids still collected (dangling edge still flagged) when a sibling id is bad.tests/test_build.pycases: build skips non-hashable/missing node ids and non-hashable edge endpoints while keeping well-formed entries.Full suite locally (
pytest tests/): 2331 passed, with the only 2 failures (test_ollama::test_detect_backend_ollama,test_detect_backend_none_without_envvars) being pre-existing and environmental — they fail identically on a pristine checkout because backend auto-detect resolves to an installed paid-API package. This change adds 5 passing tests and introduces 0 new failures.ruff checkis clean on the changed files.