Skip to content

mcp: codedb_query filter op silently no-ops and pipeline output ignores filter/limit #558

@justrach

Description

@justrach

Problem

Two compounding defects in handleQuery (src/mcp.zig):

  1. The filter op only reads ext and glob params. Any other key — e.g. the natural pattern — leaves both null, so every file passes through silently. No error, no hint. Live repro: [{op:find,query:"index.zig"},{op:filter,pattern:"src/index.zig"},{op:limit,n:3}] → stage trace 1: filter (50 files).
  2. find prints its full result list eagerly when it executes, and the final file-set print is gated on out.items.len == 0 — so in find → filter → limit pipelines the rendered output is find's pre-transform list (all 50 files), while limit only shows up in the stage tail. The output contradicts the pipeline.

Failing Test

test "issue-558: codedb_query filter must filter (or error) — never silently pass every file" in src/test_query.zig (branch fix/issue-558-query-filter):

  • pipeline find auth → filter pattern=*.py → limit 10 must list src/auth.py and must NOT list src/auth.ts/docs/auth.md
  • pipeline find auth → filter match=*.py (no recognized param) must emit error: filter needs

Verified failing on release/0.2.5825: 65/66 tests passed (1 failed) — fails at the auth.ts leak.

Expected

  • filter accepts pattern as an alias for glob (with the same bare-pattern **/ auto-promotion codedb_search applies to path_glob)
  • filter with no recognized param errors listing valid params
  • a pipeline's rendered output reflects the post-transform file set: find defers its listing when it is not the last step

Fix

src/mcp.zig handleQuery: read glob orelse pattern, error via finishQueryWithFailure when ext+glob+pattern all missing, auto-promote bare globs, and print find's list only when it is the final step (the existing tail print at the end of the pipeline already renders the final set when nothing else printed). Document filter params in the codedb_query inputSchema.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingpriority:p2Medium priority

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions