Skip to content

bug(indexer): Node identity (name, path, line_number) is not unique; symbols merge and properties are clobbered #1393

Description

@Shashankss1205

tools/indexing/persistence/writer.py:409

merge_clause = f"MERGE (n:{label} {{name: row.name, path: $file_path, line_number: row.line_number}})"
# ...
UNWIND $batch AS row
{merge_clause}
SET n += row

Two distinct symbols in one file sharing a name and a line silently become one node, and SET n += row overwrites the first's args, class_context, end_line and cyclomatic_complexity with the last's.

This is the root cause of the 5530 vs 5501 discrepancy. Re-parsing the repo with the shipped parsers:

total parsed functions: 5530
distinct merge keys:    5501
lost:                     29   (22 colliding keys)

Two sources of collision:

  • CSStools/languages/css.py:83 emits every selector as a Function. Grouped selectors (table, tbody, tr, td { }) produce several records with the same name and line.
  • Minified/bundled JSwebsite/public/wasm/tree-sitter-core.js is one line, so genuinely different functions all carry line_number: 1. Node.endIndex and TreeCursor.endIndex collapse into a single node whose class_context is whichever was written last.

Fix. Add a disambiguator to the merge key (end_line, class_context, or a per-file ordinal). At minimum, detect key collisions in add_file_to_graph and log them.


Audit environment
Version codegraphcontext 0.5.2 (PyPI)
Commit df3af04
Backend FalkorDB Lite (falkordblite 0.9.0), Python 3.12.3, Linux
Corpus the CodeGraphContext repo itself — 784 files, 23 languages, 5,501 Function nodes

Audit ID I-H05 · severity high · from an end-to-end audit of CGC 0.5.2 (63 findings). Reported with the reproduction as run.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

area: indexerParsing, discovery, resolution, persistencebugSomething isn't workingseverity: highWrong graph content, data loss, or a broken workflow with no clear signal

Type

No type

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions