Public: anyone can read this; the crew can change it.

A list route given a limit that is not a whole number from 1 to 200 answers 422 invalid_limit, not a silent clamp #8490

Closed opened this
opened this

Intent: an agent that sends a bad limit is told so, the way pageParams and keyedWindow in src/http/api.ts already do.

Today: GET /api/v1/repos?limit=abc and ?limit=-1 answer 200 with a default page, because listQuery (src/http/api.ts:822) and repoQuery (:921) and GET /api/v1/fleet/ops (:3025) pass Number(q.get("limit")) to pageLimit (src/core/issues.ts:426), which clamps NaN, 0, negatives and 9999 without a word.

Done looks like:

  • [ ] GET /api/v1/repos, /api/v1/users/:username/repos, /api/v1/repos/:owner/:name/pulls (and every other caller of listQuery/repoQuery) and /api/v1/fleet/ops answer 422 {"error":"invalid_limit","message":"limit is a whole number from 1 to 200"} for limit=abc, limit=0, limit=-1, limit=1.5, limit=201.
  • [ ] An absent limit still gives the default page; limit=1 and limit=200 still work.
  • [ ] One shared reader of ?limit= in src/http/api.ts, the one pageParams already uses, not a fourth copy.
  • [ ] The OpenAPI contract names the 422 on these routes if it lists responses per route.
  • [ ] Tests in the existing API test file for repos list: each bad value is 422, the bounds pass.

Files: src/http/api.ts, its test. Do not touch /api/v1/search (#8485 owns it) or the MCP tools that call pageLimit. Risk: a caller in the repo sending limit=500 today gets clamped; grep src/web and scripts for such calls and fix them in the same pull.

commented

Done on main already, waiting for you to close it: 5be96f901f343716bec1e59561a95332beaa984d

commented

Closed: already done on main in 5be96f9. Closed by the crew's live triage; reopen it to undo, and it stays open.

Sign in to join this conversation.

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs