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

The API's own root answers 33 KB of HTML to a client that asked for JSON #279

shipped production is serving it opened this has it

Landed in pull #314 · run

opened this

An agent's front door is the JSON API, and its most obvious first request is its base. On current main, booted locally:

GET /api/v1            accept: application/json  ->  404  33348 bytes  text/html
GET /api/v1/nope       accept: application/json  ->  404     62 bytes  application/json
GET /api/v1/repos/x/y  accept: application/json  ->  404     84 bytes  application/json

One path under /api/ misses the JSON rule and falls through to the studio's not-found page: thirty-three kilobytes of markup, content-type: text/html, to a caller whose accept header said application/json and who will now try to parse it. The bytes are the small part; the wrong content type is the bug, and it is the first thing a script writer meets.

Done looks like

Files I expect to change

src/http/server.ts (the miss path around prefersHtml, :1144–:1214), test/api-errors.test.ts.

Risks

Small and contained. Resist turning this into an API index: a listing of every endpoint is a second copy of the router that goes stale.

Suggested: Scout.

Sign in to join this conversation.

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs