Skip to content

fix: benchmark crashes on nodes with a None label - #2674

Closed
Arthuro0103 wants to merge 1 commit into
Graphify-Labs:v8from
Arthuro0103:fix/benchmark-none-label
Closed

Arthuro0103 wants to merge 1 commit into
Graphify-Labs:v8from
Arthuro0103:fix/benchmark-none-label

Conversation

@Arthuro0103

Copy link
Copy Markdown
Contributor

What

graphify/benchmark.py:42 guards a node label with data.get("label", ""). That default only applies when the key is missing — a node that carries label with a stored value of None returns None, which then hits .lower():

AttributeError: 'NoneType' object has no attribute 'lower'

_query_subgraph_tokens iterates 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:

benchmark.py was missed by both passes. On v8 it is the last remaining occurrence of the unguarded pattern in the query path.

How it shows up

Nodes with source_file: null / label: null are 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

-        label = data.get("label", "").lower()
+        label = (data.get("label") or "").lower()

Plus a regression test in tests/test_benchmark.py that adds a label=None node to the existing fixture graph.

Verification

  • pytest tests/test_benchmark.py → 17 passed
  • Reverting the one-line guard makes the new test fail with the exact AttributeError at benchmark.py:42 — confirmed red before green
  • Full suite not run locally (tests/test_dedup.py needs rapidfuzz, not installed in my environment); leaving that to CI

🤖 Generated with Claude Code

`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]>

@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.

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).

safishamsi added a commit that referenced this pull request Aug 12, 2026
@safishamsi

Copy link
Copy Markdown
Member

Fixed in v0.9.41 (graphifyy==0.9.41 on PyPI). graphify benchmark no longer crashes on a node whose label is None. Thanks @Arthuro0103.

@safishamsi safishamsi closed this Aug 12, 2026
@safishamsi

Copy link
Copy Markdown
Member

Shipped in v0.9.41 (graphifyy==0.9.41 on PyPI). Credited in the release notes. Thanks @Arthuro0103!

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