Add MCP bounty filters#286
Conversation
TateLyman
left a comment
There was a problem hiding this comment.
Thanks for adding MCP-side bounty filters. I found one blocker: the new MCP q path reintroduces the oversized numeric search crash that PR #285 just fixed for the REST/page search path.
In _call_mcp_tool() the new branch does:
issue_number = int(query_text) if query_text.isdigit() else None
...
Bounty.issue_number == issue_numberFor a very large digit-only query, Python can create the int, but SQLite cannot bind it to an INTEGER column. Direct repro on this PR head:
client.post('/mcp', json={
'jsonrpc': '2.0',
'id': 1,
'method': 'tools/call',
'params': {
'name': 'list_bounties',
'arguments': {'q': '9' * 40},
},
})Observed: OverflowError: Python int too large to convert to SQLite INTEGER escapes the request path.
Expected: the MCP filter should behave like the public bounty search path after PR #285: keep text matching, but skip the exact issue-number predicate when the numeric string exceeds the signed SQLite integer range.
Evidence checked:
- Inspected the new
list_bountiesMCP filter branch inapp/main.pyand compared it to the public bounty search overflow fix. - Inspected the new MCP filter tests in
tests/test_api_mcp.py; current invalid-filter tests cover status, non-string q, and limit bounds, but not oversized numericq. - Ran the targeted MCP filter tests:
./.venv/bin/python -m pytest tests/test_api_mcp.py::test_mcp_list_bounties_filters_status_query_and_limit tests/test_api_mcp.py::test_mcp_list_bounties_rejects_invalid_filters -q->6 passed. - Ran the direct TestClient repro above; it raises
OverflowError. - Ran
./.venv/bin/ruff check app/main.py tests/test_api_mcp.py,./.venv/bin/ruff format --check app/main.py tests/test_api_mcp.py, andgit diff --check-> passed. - Checked hosted
Quality, readiness, docs, and image checks-> passing, so this needs a new regression.
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (2)
📝 WalkthroughWalkthroughThe ChangesMCP list_bounties filtering
Sequence DiagramsequenceDiagram
participant Client
participant MCPHandler
participant Database
Client->>MCPHandler: call list_bounties(status, q, limit)
MCPHandler->>MCPHandler: validate status, q, limit
MCPHandler->>Database: query bounties with filters
Database->>Database: apply status filter (default open)
Database->>Database: apply q filter (LIKE + numeric)
Database->>Database: apply limit (max 100)
Database-->>MCPHandler: filtered bounties
MCPHandler-->>Client: list_bounties results
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
47a2f65 to
e621d31
Compare
|
Updated in e621d31. Changes after review:
Verification rerun:
|
TateLyman
left a comment
There was a problem hiding this comment.
Re-checked after commit e621d31. The blocker I raised is fixed.
What changed in this revision:
- MCP
list_bountiesnow normalizesqand only adds the exactBounty.issue_number == ...predicate when the numeric query fits SQLite signed integer range. - Oversized numeric text still goes through the escaped text search path and no longer raises
OverflowError. - Status and limit validation are covered through the MCP invalid-arguments path.
Verification run locally on the updated branch:
uv run pytest tests/test_api_mcp.py -q-> 49 passed, 1 existing httpx deprecation warning.uv run ruff check app/main.py tests/test_api_mcp.py-> passed.uv run ruff format --check app/main.py tests/test_api_mcp.py-> passed.git diff --check-> passed.
Hosted quality check is green.
Bounty #284
Summary
status,q, andlimitarguments to the MCPlist_bountiestool.tools/list.Exact MCP behavior
list_bountieswith{}still returns open bounty rows only.list_bountieswith{ "status": "paid", "q": "proof", "limit": 1 }returns matching paid bounty rows through the same JSON-RPC text content wrapper.list_bountieswith{ "status": "closed", "q": "286" }can find a closed bounty by GitHub issue number.Verification
.venv/bin/python -m pytest tests/test_api_mcp.py::test_mcp_tools_list_and_call tests/test_api_mcp.py::test_mcp_list_bounties_filters_status_query_and_limit tests/test_api_mcp.py::test_mcp_list_bounties_rejects_invalid_filters -q-> 7 passed.venv/bin/python -m pytest tests/test_api_mcp.py -q-> 47 passed, 1 warning.venv/bin/python -m pytest -q-> 215 passed, 2 warnings.venv/bin/ruff check .-> all checks passed.venv/bin/ruff format --check .-> 37 files already formatted.venv/bin/python -m mypy app-> success.venv/bin/python scripts/docs_smoke.py-> docs smoke ok.venv/bin/python scripts/check_agents.py-> AGENTS.md okgit diff --check-> cleanNo private keys, wallet material, deployment credentials, payout details, private vulnerability details, or price claims are included.
Summary by CodeRabbit