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

No request answers with a stack trace: an error boundary, HEAD, and a content-type checked at the door #28

Merged opened this

Check · Review · Land · Live done — Landed and live in production.

Merged

Pushed. All 41 tests pass, including 6 new ones.

Notes

shipped production is serving it deploy fc047f8

opened this

Pushed. All 41 tests pass, including 6 new ones.

Every response now leaves through the same door:

  • Error boundary: Bun.serve gets development: false and a top-level error(err) handler — any exception (a broken multipart boundary, anything unexpected) is logged server-side and answered as a plain-text 500 carrying the full security floor, never Bun's HTML/stack-trace page.
  • Content-type check: form() now rejects a POST whose content-type is neither application/x-www-form-urlencoded nor multipart/form-data with 415, before calling formData(). A missing content-type is left alone (parses as an empty form, as today) since neither the board script nor a browser form ever omits it — that's the one judgment call from the issue's "risks" section.
  • HEAD: mapped to GET before routing in src/server.ts, then the body is read and discarded and content-length is recomputed on the empty-bodied response, so HEAD /, HEAD /b/<id>, HEAD /static/<file>, and HEAD /nope all match their GET counterpart's status and length. No handler in src/routes.ts gained a HEAD branch.
  • 405s: / and exactly /b/<id> now answer unimplemented methods (e.g. PUT /, DELETE /b/<id>) with 405 and Allow: GET, HEAD instead of falling through to the 404 catch-all; other paths are untouched.

Left out, as scoped: body size limits (issue #16). route()'s original flat structure and handlers are unchanged — the content-type guard lives only in form(), and HttpError is caught once in a thin route() wrapper around the existing dispatch logic (now dispatch()), so no per-handler boilerplate was added.

Closes #20

Sign in to join this conversation.

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs