Skip to content

fix(mcp): filter find_issues by server in SQL, not after the limit (audit M7) - #437

Merged
passcod merged 1 commit into
mainfrom
claude/pr-370-fix-m7-mcp-find-issues
Aug 1, 2026
Merged

fix(mcp): filter find_issues by server in SQL, not after the limit (audit M7)#437
passcod merged 1 commit into
mainfrom
claude/pr-370-fix-m7-mcp-find-issues

Conversation

@passcod

@passcod passcod commented Aug 1, 2026

Copy link
Copy Markdown
Member

Fixes M7 (medium) from the audit in #370.

The bug

Issue::list orders by last_seen desc with a SQL LIMIT (default 100). find_issues then applied its server_id filter in Rust — issues.retain(…) — on that already-truncated page. Every other filter, including group_id, is part of the query; only this one bit after the fact.

With more active issues fleet-wide than the limit, a server whose issues were seen slightly earlier than the top N returns count: 0. An agent triaging that server is told it's clean when it isn't — and the quieter the server, the likelier that is, which is exactly backwards.

The fix

server_id joins the other fields on IssueListFilters and is applied in SQL, so the limit bounds the filtered set. private-server's issues::list passes None and is unaffected.

Tests

New crates/database/tests/it/issue_list_filters.rs:

  • the_server_filter_is_applied_before_the_limit — a noisy server with 10 recent issues, a quiet one whose single issue was seen longest ago, and a limit of 5: the quiet server's issue still comes back.
  • the_server_filter_excludes_other_servers — the filter does what it says.

This is one of four sites in the audit's "filter-after-LIMIT in the MCP layer" pattern (M7, M8, M9, L14); the others are separate PRs.


Generated by Claude Code

`Issue::list` orders by `last_seen desc` with a SQL `LIMIT` (100 by default);
`find_issues` then applied its `server_id` filter in Rust, on that already
truncated page. `group_id` is part of the query, so only this one filter bit
after the fact.

With more active issues fleet-wide than the limit, a server whose issues were
seen slightly earlier than the top N returns `count: 0` — an agent triaging
that server is told it is clean while it is not. The quieter the server, the
more likely it is to be misreported.

`server_id` joins the other filters in `IssueListFilters`, so the limit bounds
the filtered set.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01SGfH1cdFKPnKpM7ytRThft
@passcod
passcod marked this pull request as ready for review August 1, 2026 21:48
@passcod
passcod added this pull request to the merge queue Aug 1, 2026
Merged via the queue into main with commit 2edf53f Aug 1, 2026
7 checks passed
@passcod
passcod deleted the claude/pr-370-fix-m7-mcp-find-issues branch August 1, 2026 22:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants