Graphify-Labs/graphify · error · ValueError
Key {key!r} already exists in MinHashLSH
Error message
Key {key!r} already exists in MinHashLSH What it means
Fail-fast guard in the Windows flavor of the graphify skill template (tools/skillgen/expected/graphify__skill-windows.md:441), identical in logic to the bash variant: after build_from_json(extraction, root='INPUT_PATH', directed=IS_DIRECTED), a graph with zero nodes aborts via SystemExit(1) before any output file is written. It protects the existing graph.json / GRAPH_REPORT.md / analysis sidecar from being clobbered by an empty extraction (#1392).
Source
Thrown at graphify/_minhash.py:94
)
err = 0.5 * fp + 0.5 * fn
if err < best_err:
best_err, best = err, (b, r)
_LSH_PARAMS_CACHE[key] = best
return best
class MinHashLSH:
"""Band-hashing LSH — same API as datasketch.MinHashLSH for the subset used here."""
def __init__(self, threshold: float = 0.5, num_perm: int = 128) -> None:
self.b, self.r = _optimal_lsh_params(threshold, num_perm)
self._tables: list[dict[bytes, list[str]]] = [{} for _ in range(self.b)]
self._keys: set[str] = set()
def insert(self, key: str, minhash: MinHash) -> None:
if key in self._keys:
raise ValueError(f"Key {key!r} already exists in MinHashLSH")
self._keys.add(key)
hv = minhash.hashvalues
for i, table in enumerate(self._tables):
band = hv[i * self.r : (i + 1) * self.r].tobytes()
table.setdefault(band, []).append(key)
def query(self, minhash: MinHash) -> list[str]:
hv = minhash.hashvalues
candidates: set[str] = set()
for i, table in enumerate(self._tables):
band = hv[i * self.r : (i + 1) * self.r].tobytes()
candidates.update(table.get(band, []))
return list(candidates)
View on GitHub (pinned to 7fe58b0b0f)
Solutions
- Inspect graphify-out/.graphify_extract.json and confirm the nodes array is empty; if so, re-run extraction against a tree with real text sources.
- Verify the PowerShell invocation passed the correct INPUT_PATH (quoting/relative path issues on Windows are the usual culprit for 'scanned nothing').
- Delete the .graphify_extract.json / .graphify_detect.json sidecars and re-run the full pipeline so stale empty artifacts are not reused.
- Check the detection stage output (.graphify_detect.json) to see which files were skipped and why.
Example fix
# before: extractor ran against a binary-only folder /graphify ./dist # ERROR: Graph is empty ... # after: target the source tree, clear stale sidecars Remove-Item graphify-out\.graphify_extract.json, graphify-out\.graphify_detect.json /graphify .\src
Defensive patterns
Strategy: validation
Validate before calling
import json
from pathlib import Path
extract = json.loads(Path('graphify-out/.graphify_extract.json').read_text(encoding='utf-8'))
nodes = extract.get('nodes') or []
if not nodes:
raise SystemExit('extraction produced 0 nodes - check detection skip list before building')
detect = json.loads(Path('graphify-out/.graphify_detect.json').read_text(encoding='utf-8'))
print('nodes:', len(nodes), '| detection entries:', len(detect) if isinstance(detect, list) else 'n/a') Prevention
- Precheck the extract sidecar's nodes count before running the PowerShell build pipeline.
- Quote INPUT_PATH correctly in PowerShell so the extractor scans the intended tree.
- Run from the directory the skill expects; relative sidecar paths silently miss otherwise.
- Remove stale .graphify_extract.json/.graphify_detect.json before rebuilding.
When it happens
Trigger: Executing the PowerShell here-string pipeline (& (Get-Content graphify-out\.graphify_python) -) when .graphify_extract.json yields zero nodes: all files skipped during detection, a binary-only corpus, or an upstream extraction failure that still emitted a valid-but-empty JSON file.
Common situations: Running the skill on Windows against a directory of binaries or generated artifacts; a path-quoting mistake in PowerShell so the extractor scanned nothing; extraction stage failed (e.g. token/quota error) but wrote an empty result; line-ending or encoding corruption making every file unparseable to the detector.
Related errors
- module 'graphify' has no attribute {name!r}
- Cannot read {graph_path} for incremental merge: {exc}. Delet
- ERROR: invalid JSON in {path}: {exc}
- --cargo on Python 3.10 needs tomli. Install with: pip instal
- ERROR: Graph is empty - extraction produced no nodes.
AI-assisted analysis of Graphify-Labs/graphify@7fe58b0b0f (2026-08-14).
Data as JSON: /api/errors/b4ae776a6f85b367.
Report an issue: GitHub.