fix: normalize repo_path filters so bare repo names actually match - #1634
Open
pm-dun86 wants to merge 1 commit into
Open
fix: normalize repo_path filters so bare repo names actually match#1634pm-dun86 wants to merge 1 commit into
pm-dun86 wants to merge 1 commit into
Conversation
…odeGraphContext#1633) Every repo_path-scoped query in CodeFinder built its Cypher filter as a raw `node.path STARTS WITH $repo_path` string comparison with no normalization. Node paths are stored as the absolute filesystem path used at indexing time, so passing anything else — the repo name from list_indexed_repositories(), a relative path, a trailing slash — silently matched zero nodes, with no error surfaced to the caller. Adds _normalize_repo_path_filter(), which resolves a non-absolute repo_path against the indexed repository list (by name, basename, or cwd-relative path) before it reaches any STARTS WITH filter. Wired into every method on CodeFinder that accepts repo_path. Also replaces the unrelated but similarly broken Path(repo_path).resolve() in audit_kotlin_call_ambiguity, which resolved against the server process cwd instead of the indexed root. Verified against a local KuzuDB index containing both a Python and a Java repo: short repo names now resolve to the correct absolute root and return the expected matches, while cross-repo scoping still correctly excludes the other repo's results. Fixes CodeGraphContext#1633.
|
@ModQA is attempting to deploy a commit to the shashankss1205's projects Team on Vercel. A member of the Team first needs to authorize it. |
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.
Problem
Fixes #1633.
Every
repo_path-scoped query acrossCodeFinder(find_code,find_dead_code,who_calls_function,find_module_dependencies,find_class_hierarchy,find_most_complex_functions, and ~15 others) builds its filter as a raw string comparison:Node
.pathis stored as the absolute filesystem path used at indexing time. Passing anything else — the repo name/path exactly as returned bylist_indexed_repositories(), a relative path, a trailing slash — silently matches zero nodes, with no error. Any caller that scopes a query by repo using the tool's own advertised repo identifier gets an empty result indistinguishable from "nothing found."There's also a second, related bug in
audit_kotlin_call_ambiguity: it callsPath(repo_path).resolve(), which resolves a relativerepo_pathagainst the server process's cwd rather than the indexed root — same failure mode, different mechanism.Fix
Adds
CodeFinder._normalize_repo_path_filter():list_indexed_repositories()— matched by repo name, path basename, or full stored path (case-insensitive) — before it reaches anySTARTS WITHfilter.Wired into every
CodeFindermethod that acceptsrepo_path, includingaudit_kotlin_call_ambiguity(replacing its broken.resolve()call).Scope
This PR is deliberately narrow — just this one normalization fix, no other changes. #811 is a much larger open PR that also contains a version of this fix, but it's bundled with unrelated MCP framing and Kùzu FTS work and has significant merge conflicts against
main. Pulling this piece out separately should be easy to review/merge on its own, independent of whatever happens with the rest of #811 (see discussion there re: possible KùzuDB deprecation in #1302).Testing
tests/unit/tools/test_repo_path_normalization.pycovering: bare repo name resolution, basename resolution when repo name differs from path, absolute passthrough,Nonepassthrough, whitespace/trailing-slash handling, multi-repo disambiguation, unknown-repo passthrough, and ambiguous-basename passthrough.tests/unitsuite run before and after — no new failures (pre-existing failures are unrelated: missingpytest-asyncioplugin for a handful of async tests, and some macOS/private/varpath-normalization test fixtures).find_code(repo_path="<bare-name>")now returns the expected matches for either language, and cross-repo scoping still correctly excludes the other repo's results (no bleed-through).