Repository navigation
mcpx(daemon): reject invalid numeric query params with 400 (#3485) - #4429
Conversation
Six handlers discarded strconv.Atoi errors, treating present-invalid limit/top/budget as absent (200 with default). Add shared parseOptionalIntQuery helper (present-invalid incl. empty/banana/2.7/1e3 -> 400 naming param+value; absent -> default; valid/zero/negative -> existing defaults) and handler regressions for invalid/absent/valid/ zero/negative on all six routes.
|
Warning Review limit reachedYou've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. Next included review available in 53 minutes. View limit details
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. |
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 0573355ccc
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| // TestNumeric_log_limit pins #3485 for GET /v1/log limit. | ||
| func TestNumeric_log_limit(t *testing.T) { |
There was a problem hiding this comment.
Add a registry-driven guard for numeric query validation
The six individually named handler tests cover today's fixes, but adding another integer query parameter with an ignored parse error would leave this suite green. This violates the class-wide guard requirement in pkgs/mcpx/internal/AGENTS.md, which explicitly requires coverage of present and future members. Add a guard driven by the integer query parameter declarations in internal/api, with explicit exclusions for intentionally out-of-scope routes, so newly declared parameters cannot silently escape validation coverage.
AGENTS.md reference: pkgs/mcpx/internal/AGENTS.md:L11-L12
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Fixed in 0652386 (shepherd pass, queue task 6124):
- Added
TestNumeric_registry_guardinnumeric_params_test.go: it iterates every integer query parameter declared ininternal/api(api.Ops()) and fails unless each is either probed by aTestNumeric_*test or listed innumericGuardExcludedwith a recorded reason; it also fails on stale covered/excluded entries no longer in the registry. - The guard immediately caught a real seventh member of the class:
GET /v1/artifacts limit(handleArtifactListin routes_exec.go) discarded its Atoi error exactly the same way. It now goes throughparseOptionalIntQueryand is probed byTestNumeric_artifacts_limit. - Exclusions, with reasons recorded in the test:
GET /v1/events since(own validation track mcpx(events): the /v1/events resume contract silently breaks at since=0 and on a malformed since — a trimmed history reports no gap, and a bad cursor is coerced to 0 or MaxUint64 #1679/mcpx(daemon): /v1/interactions score filters silently misbehave — a non-numeric minScore returns the unfiltered list, NaN/Inf return an empty one #2223 — strict ParseUint 400 in the events handler) and bothwaitMsparams (pollWait hint semantics — unparseable falls back to the configured ceiling by design, errors only out-of-range).
Verified on the laptop: go test ./internal/daemon -run Numeric -count=1 all 8 pass; -race -shuffle=on -count=5 pass; full go test ./internal/daemon -count=1 pass.
|
Codex Review: Didn't find any major issues. Delightful! Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
|
Salvage comparison for duplicate/superseding PR #7241: its head is the same commit as this merged PR ( |
Fixes #3485.
Six handlers ignored strconv.Atoi errors, so a present invalid numeric query param (empty, banana, 2.7, 1e3) was treated as absent (200 with the configured default).
Tests:
Need help on this PR? Tag
@codesmith-botwith what you need.