Skip to content

bug(graph): graph_name is silently discarded for dead_code and find_complexity, querying the default graph instead of the requested one #1531

Closed

Description

@Shashankss1205

tools/code_finder.py — self._active_graph = graph_name at :1204, clobbered by :792 (find_dead_code) and :1379 (find_most_complex_functions)

analyze_code_relationships sets the active graph on the shared instance field, then dispatches to inner methods at :1275 and :1284 without forwarding graph_name. Both inner methods default the parameter to None and re-assign the same instance field, so self.driver resolves to db_manager.get_driver(None) — the default graph.

Reproduction

Instrumenting get_driver to record the graph name it receives:

dead_code       -> [None]      # graph_name="mygraph" was passed in
find_complexity -> [None]
find_callers    -> ['mygraph'] # control: forwards correctly

Impact

FalkorDB is the default backend and is multi-graph, with one graph per indexed repository. So:

analyze_code_relationships(query_type="dead_code", graph_name="myrepo")

silently queries the default graph and returns dead-code results for a different repository — or an empty list if the default graph is empty. Same for find_complexity. The caller gets a plausible-looking answer about the wrong codebase, with no error.

Suggested fix

Forward graph_name explicitly at both call sites:

-return self.find_dead_code(...)
+return self.find_dead_code(..., graph_name=graph_name)

More robustly, stop routing graph selection through mutable instance state — passing it as a parameter throughout removes this whole class of clobbering.


Environment
Commit c0e0bed (main)
Python 3.12.3, Linux

Reproduced by instrumenting get_driver and invoking each query type.

Activity

  1. added
    bugSomething isn't working
    severity: mediumIncorrect results, misleading output, or a broken contract
    area: graphDatabase abstraction, Cypher generation, schema, bundles
    on Aug 1, 2026
  2. github-actions commented on Aug 1, 2026

    @github-actions
    Contributor

    Hi! 👋 Join our CodeGraphContext Discord channel to collaborate: https://discord.gg/dR4QY32uYQ

  3. Shashankss1205 commented on Aug 5, 2026

    @Shashankss1205
    CollaboratorAuthor

    Fixed in #1577 (merged).

    graph_name is now forwarded explicitly at both dispatch sites:

    results = self.find_dead_code(repo_path=repo_path, graph_name=graph_name)
    results = self.find_most_complex_functions(limit, repo_path=repo_path, graph_name=graph_name)

    Regression test spies on both inner methods and asserts the value arrives.

    The deeper point in the issue stands and is worth revisiting separately: routing graph selection through the mutable self._active_graph is what made this possible in the first place, and passing it as a parameter throughout would make the whole class of bug structurally impossible.

  4. moved this from Backlog tasks to Done in CGC Progress Boardon Aug 5, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    area: graphDatabase abstraction, Cypher generation, schema, bundlesbugSomething isn't workingseverity: mediumIncorrect results, misleading output, or a broken contract

    Type

    No type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions