Repository navigation
Closed
Description
Problem
- A malformed JSON body on any path, without credentials, returns an HTML error page:
curl -X POST <api>/api/tasks/revert -H "Content-Type: application/json" -d '{"a":'→ 400text/html<pre>SyntaxError: Unexpected end of JSON input … at parse (/usr/src/app/node_modules/body-parser/lib/types/json.js:93:21). WithNODE_ENV=productionthe stack is omitted but the response is still HTML. Same forContent-Encoding: gzipwith garbage (Error: incorrect header check … node:zlib), an unsupported charset (415 HTML) and a body over the limit (413).express.json()is mounted inpackages/api/server.tswith no error handler. - Unknown paths under
/api/return Express's HTML page (Cannot GET /api/config) instead of JSON. GET /api/activity?offset=99999999999999999999(or the same value aslimit) returns 500;?limit=-1or?limit=1000000000returns the whole log (about 237 KB instead of 13 KB);limit=abcis silently ignored (packages/api/routes/queueRoutes.ts,parseInt(...) || 50passed to RedislRange).GET /api/github/repos/..%2f..%2fetc%2fpasswd/propr/branchesand/workflowsreturn 500 "Failed to fetch branches from GitHub" instead of 400/404.GET /api/agent-definitions/templatesreturns 404 "Automation definition not found" (the alias treatstemplatesas an id) whileGET /api/automation-definitions/templatesworks; every other route of the alias works.- Every response carries
X-Powered-By: Express; there is noX-Content-Type-Options: nosniff;Access-Control-Allow-Credentials: trueis sent even when the request has no Origin; 401 responses have noWWW-Authenticate. GET /api/task/{id}/history,/file-changesand/live-detailsreturn 200 with empty data for a task id that does not exist (the UI and CLI then show a nonexistent task as pending);docker-logsreturns 404.
Expected / acceptance criteria
- 1, 2: every error produced by the API process under
/api/,/healthand/mcpis JSON{ "error": …, "code": … }with the right status (400 invalid JSON, 413 too large, 415 unsupported media type, 404 unknown route) and contains no stack trace or file path in anyNODE_ENV. - 3:
limitandoffsetare validated integers (limit 1–200, offset ≥ 0); invalid values are 400. - 4: owner/repo path segments are validated; invalid ones are 400.
- 5: the alias serves
templateslike the canonical route. - 6:
x-powered-bydisabled;X-Content-Type-Options: nosniffon API responses;Access-Control-Allow-Credentialsonly on responses to an allowed Origin;WWW-Authenticate: Beareron 401. - 7: the three task routes return 404 for an unknown task id.
- Tests for each point; the OpenAPI spec is regenerated if response codes change.
Implementation
packages/api/server.ts (body-parser error middleware placed after the parsers, a JSON 404 for unmatched /api routes, app.disable('x-powered-by')), packages/api/routes/queueRoutes.ts, the GitHub proxy routes, the automation definition alias registration, the task detail routes. Check that the web UI and CLI handle the new 404 on task routes (see the related CLI and navigation issues in the other 0.9.2 release-fix plans; do not duplicate their work).
Notes
Do not change CORS origin rules. Do not add a dependency for headers; set them directly.
Activity
propr-dev commentedon Nov 17, 2026
🤖 AI processing has started for this issue using claude agent with claude-opus-5-5 model.
I'll analyze the problem and work on a solution. This may take a few minutes.
Processing Details:
claudeclaude-opus-5-53617/claude-opus-5-5-api-json-errors-for-malfo-20261117-0149-myt3616-epic-0-9-d8bissue-3617-20261117-0149-claude-opus-5-5-myt🔍 Track Task Execution
I've implemented all seven points of #3617. The new tests and the aff…
[3617 by Claude Opus 5.5] API: JSON errors for malformed bodies and u…