Repository navigation
Description
Summary
graphify extract --backend ollama crashes with TypeError: expected string or bytes-like object, got 'int' during the final dedup/build step when the LLM backend emits a node with a non-string (integer) id field. dedup.py's _score() calls a regex .search() directly on n["id"] with no type check/coercion.
Traceback
Traceback (most recent call last):
File "<frozen runpy>", line 198, in _run_module_as_main
File "<frozen runpy>", line 88, in _run_code
File "graphify.exe\__main__.py", line 10, in <module>
sys.exit(main())
File ".../graphify/__main__.py", line 466, in main
_run_cli()
File ".../graphify/__main__.py", line 708, in _run_cli
dispatch_command(cmd)
File ".../graphify/cli.py", line 3199, in dispatch_command
G = _build_merge([merged], ..., root=target)
File ".../graphify/build.py", line 1023, in build_merge
G = build(all_chunks, directed=directed, dedup=dedup, dedup_llm_backend=dedup_llm_backend, root=root)
File ".../graphify/build.py", line 864, in build
combined["nodes"], combined["edges"] = deduplicate_entities(
combined["nodes"], combined["edges"], communities={},
dedup_llm_backend=dedup_llm_backend,
)
File ".../graphify/dedup.py", line 487, in deduplicate_entities
winner = _pick_winner([node, neighbor])
File ".../graphify/dedup.py", line 561, in _pick_winner
return min(nodes, key=_score)
File ".../graphify/dedup.py", line 558, in _score
has_suffix = bool(_CHUNK_SUFFIX.search(n["id"]))
TypeError: expected string or bytes-like object, got 'int'
Root cause
For at least some image-file chunks, the LLM backend returned a node with a bare integer id instead of a string, e.g. (found in the semantic cache):
{
"id": 10,
"file_type": "image",
"source_file": "Android-Cookbook-Examples-master/RecyclerViewDemo/app/src/main/res/mipmap-xhdpi/ic_launcher.png",
"label": "Launcher Icon (XHDPI)"
}{
"id": 12,
"file_type": "image",
"source_file": "<another mipmap-density variant of the same launcher icon>"
}Both confirmed occurrences are Android launcher-icon images at different mipmap densities. Both instances crashed the entire extraction run (a large, multi-hour, otherwise-successful pass over a 10k+ file corpus) at the very last step, after all AST + semantic extraction had already completed and been cached.
Repro context
graphify extract . --backend ollama --model qwen2.5-coder:3b --max-concurrency 1- Corpus: ~10,600 code files + ~800 docs + ~4,600 images (large mixed reference/sample-code corpus, not a single project)
- Windows, graphify installed via
uv tool install
Suggested fix
In dedup.py's _score() (and anywhere else a node id is assumed to be a string), coerce with str(n["id"]) before matching, or validate/normalize id to string immediately after parsing LLM output, before it reaches the dedup/build pipeline. Coercing at ingestion is probably more robust since other downstream code likely makes the same string assumption about id.
Workaround used
Excluded image extensions via .graphifyignore (*.png, *.jpg, etc.) for this corpus and re-ran — unblocks the crash, at the cost of losing image nodes (acceptable for our use case, images are low-value nodes for a code-reference corpus anyway).
Activity
chore: bump to 0.9.32; changelog for #2333/#2334/#2336/#2342/#2326/#2323
fix(build): coerce non-string node ids so a numeric id cannot abort t…
fix(build): coerce non-string node ids so a numeric id cannot abort t…
chore: bump to 0.9.32; changelog for Graphify-Labs#2333/Graphify-Labs…
fix: compare node ids and hyperedge members in the same coerced space
fix(build): coerce numeric hyperedge members under the members/node_i…