Skip to content

fix(search): name the filter when a filtered codebase_search finds nothing - #210

Merged
giancarloerra merged 1 commit into
giancarloerra:mainfrom
gnyan-zadara:fix/issue-207-search-filter-no-match-hint
Oct 23, 2026
Merged

giancarloerra merged 1 commit into
giancarloerra:mainfrom
gnyan-zadara:fix/issue-207-search-filter-no-match-hint

Conversation

@gnyan-zadara

@gnyan-zadara gnyan-zadara commented Oct 21, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Fixes #207 as proposed in the issue thread: a filtered codebase_search that finds nothing now says which filter matched nothing and what form it accepts, instead of telling the caller to index an already-indexed project. fileFilter and languageFilter remain exact keyword matches; there is no payload change and no reindex.

Before, a directory filter returned:

No results found for "<query>" in project <path>.
Make sure the project has been indexed first using codebase_index.

Now:

No results found for "<query>" in project <path>: fileFilter "pkg/" matched no indexed file.
fileFilter takes one file path exactly as a result header shows it (e.g. src/index.ts); directories, globs, lists and bare names of files below the root match nothing. Omit fileFilter to search everything.

Changes

  • src/tools/query-tools.ts: when a filter is set and nothing comes back before the minScore cut, filteredNoResultsLines builds the reply:

    • indexing in progress: the filter hint, plus a note that matching files may not be indexed yet and codebase_status shows progress;
    • the collection holds no chunks: the existing "index first" hint, unchanged;
    • otherwise: the filter hint. When both filters are set they are named together, since the search requires both to match, so a correct fileFilter is not blamed for a wrong languageFilter.
    • With includeLinked, the reply names the filters but states no cause, because searchMultipleCollections skips a collection whose query failed, so an empty result does not prove the filter matched nothing.

    The minScore reply and the unfiltered reply are unchanged.

  • src/index.ts, skills/codebase-exploration/SKILL.md, skills/codebase-exploration/references/tool-reference.md, DEVELOPER.md: the fileFilter and languageFilter descriptions state the exact-match form, tied to what a result header shows (--- <relativePath> (lines …) [<language>]). The "Use fileFilter when you know the area" tip no longer suggests a directory.

A filtered search on a project that was never indexed still fails earlier, with Qdrant's Not Found from the search itself, so it never reaches this branch. I left that out of scope here and can follow up separately if you'd like.

Type of change

  • Bug fix (non-breaking change that fixes an issue)
  • New feature (non-breaking change that adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation update
  • Refactoring (no functional changes)
  • Test coverage improvement

Testing

  • Unit tests pass (npm run test:unit)
  • Integration tests pass (npm run test:integration)
  • TypeScript compiles cleanly (npx tsc --noEmit)
  • New tests added for new/changed functionality

Unit tests in tests/unit/query-tools.test.ts cover a fileFilter miss, a languageFilter miss, both filters together, a miss while indexing runs, a miss on an empty collection, and a filtered includeLinked miss. A new integration test in tests/integration/tools.test.ts checks that an exact relative path returns only that file's chunks; with the Qdrant relativePath filter deliberately broken it fails. Against a live index, README.md and package.json at the project root match by bare name, while index.ts for src/index.ts does not, which is what the new wording says.

Checklist

  • My code follows the existing code style and conventions
  • I have added/updated JSDoc comments where appropriate
  • I have updated documentation (README.md / DEVELOPER.md) if needed
  • I have addressed all CodeRabbit review comments (or marked as resolved with explanation)
  • I have read the Contributing Guide
  • I agree to the Contributor License Agreement

Related issues

Fixes #207

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Enhancements

    • Improved code search filtering to require exact file paths and language labels shown in results.
    • Added clearer feedback when filters return no matches, including indexing status and linked-project search context.
  • Documentation

    • Updated code search guidance to explain exact file and language filter matching.
  • Tests

    • Added coverage for file, language, combined, linked-project, indexing, and empty-result scenarios.

…thing

fileFilter and languageFilter are exact keyword matches, so a directory,
glob, bare name of a nested file, or language alias matches nothing. The
empty result then told the caller to index an already-indexed project.

A filtered search that returns nothing now names the filter and the form
it accepts. It keeps the indexing hint when the collection holds no
chunks, adds a codebase_status note while indexing is in progress, names
both filters together when both are set, and states no cause across
linked projects, where a failed collection search is skipped. The
minScore and unfiltered replies are unchanged.

The fileFilter and languageFilter descriptions and the
codebase-exploration skill docs now state the exact-match form.

Closes giancarloerra#207

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Oct 21, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: Repository: giancarloerra/SocratiCode/.coderabbit.yaml
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 637e1570-b273-419f-b611-3c236de21a18
📥 Commits

Reviewing files that changed from the base of the PR and between eb94e07 and 5f42476.

📒 Files selected for processing: 7
  • DEVELOPER.md
  • skills/codebase-exploration/SKILL.md
  • skills/codebase-exploration/references/tool-reference.md
  • src/index.ts
  • src/tools/query-tools.ts
  • tests/integration/tools.test.ts
  • tests/unit/query-tools.test.ts

Included review availability: This review used your included allowance. Your plan provides up to 8 included reviews per hour; 7 remain after this review.

📝 Walkthrough

The pull request documents exact-match requirements for codebase_search filters and adds filter-specific no-result messages. Tests cover exact file results and diagnostic messages for unmatched filters, indexing progress, linked projects, and empty indexes.

Changes: Codebase search filters

Layer / File(s) Summary
Document exact filter matching
DEVELOPER.md, skills/codebase-exploration/SKILL.md, skills/codebase-exploration/references/tool-reference.md, src/index.ts, tests/integration/tools.test.ts
Documentation states that fileFilter requires an exact result-header file path and languageFilter requires an exact result-header language label. An integration test checks that results match the requested file path.
Report filtered-search diagnostics
src/tools/query-tools.ts, tests/unit/query-tools.test.ts
Filtered searches with no results now report filter mismatches and indexing status, and indicate whether linked projects were searched. Tests cover these cases and empty indexes.

Priority: ➖ Normal

Estimated code review effort: 3 (Moderate) | ~20 minutes

Change: Bug fix · Severity of issue fixed: Medium

Suggested reviewers: giancarloerra

Merge Risk: ⚪ Minimal · up to 5f424

The documented filter values match search results, and score-only misses retain their existing explanation. No identified issue blocks merging after normal checks.

Security architecture risk: ⚪ Minimal · up to 5f424

The change improves search guidance without changing which projects or files can be searched. Existing filter matching and search controls remain unchanged, and no material security risk was identified in the changed behavior.

Retained concerns
No architecture-level concerns identified.

Security review details

Security Blast Radius

  • inferred — The incremental exposure is limited to diagnostic text and an existing collection-metadata read for the already selected project. The changed path does not expand project selection, return additional source content, or acquire write authority.

Trust Boundaries and Controls

  • observed — Caller-provided filters still pass through the existing search path. The suggestion to omit fileFilter is response text only; the implementation does not automatically broaden the query or cross into additional linked collections.
Pre-merge checks: Passed 5
Check name Status Explanation
Title check Passed The title clearly and concisely describes the main change: filtered codebase_search now identifies the filter when no results are found.
Description check Passed The description follows the required template and covers the summary, changes, type, testing, checklist, and related issue. It includes implementation details and test coverage. The CodeRabbit review …
Linked Issues check Passed Issue #207 permits filter-aware guidance instead of directory-prefix support. filteredNoResultsLines identifies fileFilter and languageFilter, states their exact-match forms, handles both filter…
Out of Scope Changes check Passed The reported changes stay within issue #207. The production change updates filtered empty-result guidance. Documentation explains the existing exact filter semantics. Unit and integration tests verify…
Docstring Coverage Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 4 functions across 4 files. (3 skipped: 3 …
Full details: Description check

Explanation

The description follows the required template and covers the summary, changes, type, testing, checklist, and related issue. It includes implementation details and test coverage. The CodeRabbit review item remains unchecked, but this is non-critical and the description is otherwise complete.

Full details: Linked Issues check

Explanation

Issue #207 permits filter-aware guidance instead of directory-prefix support. filteredNoResultsLines identifies fileFilter and languageFilter, states their exact-match forms, handles both filters together, and separates indexing-in-progress and empty-collection cases. The helper preserves the existing minScore and unfiltered branches. src/index.ts and the listed documentation files describe the same exact-match behavior. Unit tests cover the required filtered-miss cases, and the integration test verifies exact relative-path filtering.

Full details: Out of Scope Changes check

Explanation

The reported changes stay within issue #207. The production change updates filtered empty-result guidance. Documentation explains the existing exact filter semantics. Unit and integration tests verify the new guidance and exact-path behavior. No filter payload, index behavior, or reindex operation changes. The never-indexed-project behavior remains explicitly out of scope and is not presented as an unmet issue requirement.

Full details: Docstring Coverage

Explanation

Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 4 functions across 4 files. (3 skipped: 3 unsupported.)

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Comment @coderabbitai help to get the list of available commands.

@giancarloerra

Copy link
Copy Markdown
Owner

CI is approved and all 10 checks passed on 5f42476. This follows the scope agreed in #207: exact-filter documentation and filter-aware empty-result guidance, without changing filter semantics or index data. The initial CodeRabbit review is still pending.

@giancarloerra giancarloerra added the review-ready Maintainer-approved for CodeRabbit review label Oct 21, 2026
@giancarloerra

Copy link
Copy Markdown
Owner

All 10 CI checks and the substantive CodeRabbit review completed successfully on 5f42476. No further corrections are requested. Ready for a merge decision.

@giancarloerra giancarloerra self-assigned this Oct 23, 2026
@giancarloerra
giancarloerra merged commit dae6d3a into giancarloerra:main Oct 23, 2026
11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

review-ready Maintainer-approved for CodeRabbit review

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: codebase_search's fileFilter matches only one exact file path, and any other value is answered as if the project were not indexed

2 participants