Skip to content

fix: callers_of returns cross-file callers regardless of same-file caller presence#486

Open
mvanhorn wants to merge 1 commit into
tirth8205:mainfrom
mvanhorn:fix/8205-crg-callers-of-cross-file-callers
Open

fix: callers_of returns cross-file callers regardless of same-file caller presence#486
mvanhorn wants to merge 1 commit into
tirth8205:mainfrom
mvanhorn:fix/8205-crg-callers-of-cross-file-callers

Conversation

@mvanhorn
Copy link
Copy Markdown

Summary

query_graph callers_of <function> silently dropped cross-file callers when any same-file caller existed for the target. The early-return at the same-file scan path didn't continue into the cross-file sweep, so the response was incomplete depending on the call graph shape rather than the user's query intent.

Fix the same-file scan to always feed into the cross-file aggregator (don't short-circuit), and add regression tests at the query layer that cover same-file-only, cross-file-only, and mixed scenarios.

Why this matters

#472 (filed by @nicobailon) reports the missing callers in real codebases. Once you have multiple callers in the same file, the cross-file ones drop out of the tool result, which defeats the point of asking for the call graph in the first place. The fix is contained to code_review_graph/tools/query.py's callers_of path; the SQL-side aggregation already produced the right result, the bug was in how the Python layer narrowed the iterator.

Tests: uv run pytest tests/test_tools.py -k "callers_of or test_query" -> 4 passed.

closes #472

AI was used for assistance.

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.

query_graph callers_of misses cross-file callers when any same-file caller exists

1 participant