Repository navigation
Description
mcpx(daemon): six handlers silently discard invalid numeric query params — ?limit=banana returns 200 with the default-sized result, indistinguishable from a valid request
Evidence (verified this run, main 69632f23)
Six /v1 handlers parse a numeric query parameter with strconv.Atoi and discard the error (limit, _ := / top, _ := / budget, _ :=). A parse failure yields 0, which each handler then replaces with its configured default — so a present-but-invalid value is silently treated as absent:
| Route | Param | Site |
|---|---|---|
GET /v1/log |
limit |
pkgs/mcpx/internal/daemon/ops.go:131 |
GET /v1/stats |
top |
pkgs/mcpx/internal/daemon/ops.go:203 |
GET /v1/registry/search |
limit |
pkgs/mcpx/internal/daemon/ops.go:278 |
GET /v1/recipes?q=… |
limit |
pkgs/mcpx/internal/daemon/routes_consumer.go:157 |
GET /v1/search |
limit |
pkgs/mcpx/internal/daemon/server.go:941 |
GET /v1/catalog |
budget |
pkgs/mcpx/internal/daemon/server.go:988 |
Verified with a probe on the laptop (test file pkgs/mcpx/internal/daemon/probe_laneA_test.go in worktree ~/git/fleet/probe-2026-11-01-laneA-mcpxlimit/; ops.go/server.go/routes_consumer.go md5-identical to this main — 187cd534/d1d900c9/f1b056c6; real handlers via httptest, empty store; go test PASS, log in the probe dir):
GET /v1/log?limit=5(control) → 200{"records":[]}GET /v1/log?limit=banana→ 200{"records":[]}— identical to the controlGET /v1/log?limit=2.7→ 200;?limit=1e3→ 200GET /v1/log?since=banana(same handler, contrast) → 400 naming the bad value — the handler already rejects one invalid parameter and silently defaults anotherGET /v1/stats?top=5(control) → 200;?top=banana→ 200;?top=2.7→ 200
Why it matters
This is the exact silent-drop shape the daemon has already ruled against twice: #1679 made a malformed since/Last-Event-ID on /v1/events a 400 naming the parameter, and #2223 (closed) did the same for minScore/maxScore/limit/offset on /v1/interactions, with the comment in routes_feedback.go recording the rule: "silently dropping a bound made a typo'd minScore return the unfiltered list with 200 … both read as real answers." A caller who typos limit/top/budget on these six routes still gets a real-looking 200 answer computed with a different bound than the one they asked for — a truncated-looking result set, a stats table aggregated over the default top-N, or a catalog built to the default budget — with no signal anything was ignored.
Negative values have the same fate today (limit=-5 on /v1/log reaches logstore as a non-positive limit and becomes the default there), so the fix should state the rule for them rather than leaving a second silent path.
Acceptance criteria
- A present-but-unparseable numeric parameter on all six routes above is a 400 naming the parameter and the bad value (the
parseIntParamshape already inroutes_feedback.go, ideally factored so the handlers share one helper). - Absent parameter behaviour is unchanged: the configured default applies, exactly as today.
- Valid values behave exactly as today, including the existing clamping/defaulting for
0and negative values — or, if a negative is also made a 400, that is stated in the PR and pinned by a test (no silent change either way). - Regression tests per route (handler-level, following
events_cursor_test.go/routes_feedback_test.go): invalid spellings (banana,2.7,1e3) → 400; absent → 200 with default; valid → 200. - No other query parameters or routes change behaviour.
Distinct from: #2223 (closed; /v1/interactions only — its fix did not touch these six handlers), #1679 (closed; /v1/events cursors), #2878 (/v1/complete value cap, different mechanism).
Activity
developing-today commentedon Nov 1, 2026
CODE-1333
dezren39 commentedon Nov 1, 2026
🤖 Agent note · filed
22 remaining items
dezren39 commentedon Nov 2, 2026
🤖 Agent note · parked awaiting CI
06523865ec88ff148ab669d056a693d679b85535is open and mergeable; current required guard passed; local targeted, full daemon, and race/shuffle tests pass.mcpx-testrun 41494828805 remains queued after the 5-minute poll window. Currentmainhas nopull_requestormerge_grouptrigger inmcpx-test.ymlornix-ci.yml, so policy-listed PR checks were missing;.github/scripts/check-proxy-port-fallbacks.shpassed locally..github/ci-policy.mdmcpx(daemon): reject invalid numeric query params with 400 (#3485) (#…
dezren39 commentedon Nov 2, 2026
{"schema":"agent-note:v1","type":"status","stage":"done","task_id":6124,"lane":"code-d","worker":"repo-worker-code","note":"Merged on resume: PR #4429 (squash a3a15ba) - invalid numeric query params now return 400 naming parameter/value on all six mcpx daemon routes, with the registry-driven guard test. Codex: the one P1 finding was fixed in head 0652386 and replied on-thread; the Codex re-review of that head completed with no issues. The manual mcpx-test run 41494828805 was still queued on the known runner backlog at merge time; merge proceeded per standing merge authority (diff verified, Codex clean, prior local daemon tests passed per task 6124 checkpoint)."}