Repository navigation
fix: benchmark crashes on nodes with a None label - #2674
Arthuro0103 wants to merge 1 commit into
Conversation
`data.get("label", "")` only substitutes the default when the key is
MISSING. A node can carry `label` with a stored value of None — and that
None reached `.lower()`:
AttributeError: 'NoneType' object has no attribute 'lower'
`_query_subgraph_tokens` scans every node before returning, so one such
node broke the entire benchmark rather than just its own score.
The same guard was already applied across serve.py (#323) and the wiki
path (#1016); benchmark.py was missed by both.
Added a regression test that reproduces the AttributeError when the
guard is removed.
Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
There was a problem hiding this comment.
Graphify reviewed this change.
Looks safe to merge — no coupling regressions and no blocking issues, checked against the code graph (not a self-assessment).
Formal verification. 1 change(s) tested, no difference found (not proven).
Graphify review — findings
This pull request modifies _query_subgraph_tokens in graphify/benchmark.py to handle nodes whose label attribute is explicitly set to None (rather than absent), by falling back to an empty string before calling .lower(). It adds a corresponding test in tests/test_benchmark.py that constructs a graph containing a node with a None label and asserts the function still returns a positive token count.
No blocking issues surfaced.
Analysis details — impact, health, verification
Impact & health
Graphify review
Impact — 184 functions depend on the 37 functions this change touches.
Health — this change adds coupling hotspots:
- worse:
_query_subgraph_tokens()— 7 callers, 3 callees
Verification — 184 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: 45 function(s) in the blast radius were not formally verified this run
Formal verification
No difference found (not proven): No behavior difference found in \_query\_subgraph\_tokens (not a proof).
The verifier ran both versions of \_query\_subgraph\_tokens on many inputs and saw identical behavior every time. Strong evidence the change is safe, but evidence, not a proof.
Guarantee: Empirical: differential testing (both versions run on many generated inputs). A divergence on an untested input remains possible, so this is 'no counterexample found', not 'proven equivalent'.
Note: An input the sampler did not try could still differ.
· 1 more finding(s) on lines outside this diff (see the check run).
Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
|
Fixed in v0.9.41 ( |
|
Shipped in v0.9.41 ( |
What
graphify/benchmark.py:42guards a node label withdata.get("label", ""). That default only applies when the key is missing — a node that carrieslabelwith a stored value ofNonereturnsNone, which then hits.lower():_query_subgraph_tokensiterates every node before returning, so a single such node takes down the whole benchmark rather than just scoring itself as zero.Why it's still here
This exact guard was already rolled out elsewhere:
serve.py— all.get("label", "")calls guarded withor ""(AttributeError in _score_nodes when source_file is None #323)source_filepath (TypeError in export wiki: '<' not supported between str and NoneType when source_file is None #1016)benchmark.pywas missed by both passes. Onv8it is the last remaining occurrence of the unguarded pattern in the query path.How it shows up
Nodes with
source_file: null/label: nullare produced by entity extraction when no source file resolves. Hit in the wild on a 6028-node graph where 6 nodes had a null attribute — enough to break every query against it.Change
Plus a regression test in
tests/test_benchmark.pythat adds alabel=Nonenode to the existing fixture graph.Verification
pytest tests/test_benchmark.py→ 17 passedAttributeErroratbenchmark.py:42— confirmed red before greentests/test_dedup.pyneedsrapidfuzz, not installed in my environment); leaving that to CI🤖 Generated with Claude Code