Skip to content

fix: normalize repo_path filters so bare repo names actually match - #1634

Open
pm-dun86 wants to merge 1 commit into
CodeGraphContext:mainfrom
pm-dun86:fix/find-code-repo-path-normalization
Open

fix: normalize repo_path filters so bare repo names actually match#1634
pm-dun86 wants to merge 1 commit into
CodeGraphContext:mainfrom
pm-dun86:fix/find-code-repo-path-normalization

Conversation

@pm-dun86

Copy link
Copy Markdown

Problem

Fixes #1633.

Every repo_path-scoped query across CodeFinder (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:

repo_filter = "AND node.path STARTS WITH $repo_path" if repo_path else ""

Node .path is stored as the absolute filesystem path used at indexing time. Passing anything else — the repo name/path exactly as returned by list_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 calls Path(repo_path).resolve(), which resolves a relative repo_path against the server process's cwd rather than the indexed root — same failure mode, different mechanism.

Fix

Adds CodeFinder._normalize_repo_path_filter():

  • Absolute input passes through unchanged.
  • Non-absolute input is resolved against list_indexed_repositories() — matched by repo name, path basename, or full stored path (case-insensitive) — before it reaches any STARTS WITH filter.
  • Falls back to a cwd-relative resolution for CLI-style usage.
  • If nothing matches (or the match is ambiguous across multiple repos), returns the input unchanged rather than guessing — same behavior as today, no new false positives.

Wired into every CodeFinder method that accepts repo_path, including audit_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

  • New unit tests in tests/unit/tools/test_repo_path_normalization.py covering: bare repo name resolution, basename resolution when repo name differs from path, absolute passthrough, None passthrough, whitespace/trailing-slash handling, multi-repo disambiguation, unknown-repo passthrough, and ambiguous-basename passthrough.
  • Full tests/unit suite run before and after — no new failures (pre-existing failures are unrelated: missing pytest-asyncio plugin for a handful of async tests, and some macOS /private/var path-normalization test fixtures).
  • Manually verified end-to-end against a local KuzuDB index containing both a Python repo and a Java repo: 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).

…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.
@vercel

vercel Bot commented Aug 14, 2026

Copy link
Copy Markdown

@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.

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

Labels

None yet

Projects

Status: Backlog tasks

Development

Successfully merging this pull request may close these issues.

bug(mcp): find_code repo_path filter resolves against server cwd, not indexed root — silently returns 0 results

2 participants