Skip to content

mcpx(daemon): reject invalid numeric query params with 400 (#3485) - #4429

Merged
dezren39 merged 2 commits into
mainfrom
queue/6124-3485-mcpx-numeric-params
Nov 2, 2026
Merged

dezren39 merged 2 commits into
mainfrom
queue/6124-3485-mcpx-numeric-params

Conversation

@dezren39

@dezren39 dezren39 commented Nov 2, 2026 •

Copy link
Copy Markdown
Member

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).

  • Add shared parseOptionalIntQuery helper: present-invalid → 400 naming param+value; absent → default; valid/zero/negative → existing defaults (zero/negative resolve to each route's configured default, pinned by tests).
  • Apply to: GET /v1/log limit, /v1/stats top, /v1/registry/search limit, /v1/recipes limit, /v1/search limit, /v1/catalog budget.
  • Out of scope untouched: /v1/interactions, /v1/events, /v1/complete.

Tests:

  • go test ./internal/daemon -run 'numeric|limit|budget|top' -count=1 — all six pass (run in pkgs/mcpx).
  • go test ./internal/daemon -count=1 — pass.

View with [code]smith Autofix with [code]smith
Need help on this PR? Tag @codesmith-bot with what you need.

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.
@dezren39
dezren39 requested a review from a team as a code owner November 2, 2026 15:37
@coderabbitai

coderabbitai Bot commented Nov 2, 2026 •

Copy link
Copy Markdown

Warning

Review limit reached

You'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.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

Learn how review limits work.

Review configuration:

Run configuration
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: df226f71-f533-4f27-9e54-d3d56d8dd72a
Commits

Reviewing files that changed from the base of the PR and between e1fc851 and 0652386.

Files selected for processing: 6
  • pkgs/mcpx/internal/daemon/numeric_param.go
  • pkgs/mcpx/internal/daemon/numeric_params_test.go
  • pkgs/mcpx/internal/daemon/ops.go
  • pkgs/mcpx/internal/daemon/routes_consumer.go
  • pkgs/mcpx/internal/daemon/routes_exec.go
  • pkgs/mcpx/internal/daemon/server.go
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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.

Share

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 2, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-02T17:16:45.243166Z 0652386 Manual request
ℹ️ 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" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 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".

Comment on lines +96 to +97
// TestNumeric_log_limit pins #3485 for GET /v1/log limit.
func TestNumeric_log_limit(t *testing.T) {

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge 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 👍 / 👎.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in 0652386 (shepherd pass, queue task 6124):

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.

@dezren39

dezren39 commented Nov 2, 2026

Copy link
Copy Markdown
Member Author

@codex review — guard added in 0652386, see the reply on your P1 thread.

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Delightful!

Reviewed commit: 06523865ec

ℹ️ 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".

@dezren39
dezren39 merged commit a3a15ba into main Nov 2, 2026
3 of 5 checks passed
@dezren39
dezren39 deleted the queue/6124-3485-mcpx-numeric-params branch November 2, 2026 18:22
@dezren39
dezren39 restored the queue/6124-3485-mcpx-numeric-params branch November 8, 2026 04:21
@dezren39

Copy link
Copy Markdown
Member Author

Salvage comparison for duplicate/superseding PR #7241: its head is the same commit as this merged PR (06523865ec88ff148ab669d056a693d679b85535). After merging current main d7ad9d05efcf48d5a75b851a12e6476cb4776dab into the #7241 branch, git diff origin/main HEAD is empty. Therefore #7241 has no unique remaining content to salvage: its artifact-list invalid-limit fix and registry-driven numeric-parameter coverage are already included in this PR’s merged head/tree on main. No changes from #7241 are omitted.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

1 participant