fix: callers_of returns cross-file callers regardless of same-file caller presence#486
Open
mvanhorn wants to merge 1 commit into
Open
Conversation
…ller presence closes tirth8205#472
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.