Skip to content

A request body is bounded before anything is parsed

The cheapest refusals come first. A body that is too large, too deeply nested, or not JSON at all is turned away before any workflow-level meaning is read out of it.

The rule

Normative: this is the rule
  1. A request body MUST be JSON whose top level is an object or an array.
  2. Every endpoint that takes a JSON body MUST support the media type application/json.
  3. A media type of application/json with parameters, such as charset=utf-8, MUST be treated as application/json.
  4. A request that carries content with no Content-Type, or with a media type the endpoint does not support, MUST be refused with 415.
  5. That refusal MUST be made whatever the body holds, so it is answered ahead of every other check of the body.
  6. A body that exceeds 8 MiB of octets MUST be refused with 413.
  7. It MAY be refused without being read whole.
  8. A body that is empty where the endpoint requires one, is not well-formed JSON, or nests 64 levels or deeper MUST be refused with 400.
  9. A body nested too deep is refused like a broken one because an implementation may stop reading at the depth limit, and so cannot always tell a body nested too deep from one that is broken further on.
  10. A body that is both over the size limit and unreadable MAY be refused with either 413 or 400.
  11. A body that was read but whose top level is a scalar (null included) MUST be refused with 422.
  12. Nothing is stored when a body is refused.
  13. An implementation MUST accept a document nested 63 levels deep.
  14. Every refusal here MUST carry the error_code (API-8) that goes with its status: UNSUPPORTED_MEDIA_TYPE with 415, REQUEST_BODY_TOO_LARGE with 413, and INVALID_REQUEST_BODY with 400 and with the 422 for a scalar top level.

What it means

This is the storage endpoints' own copy of the gate API-1 describes: the same checks, with the numbers fixed. A body sent as something other than JSON, over 8 MiB, malformed, nested 64 levels or deeper, or not an object or array at its top level never reaches workflow-level meaning.

Each check has its own status, and the line between them is one question: could a JSON value be read from the body within the limits? A body sent under the wrong media type is 415, decided on the headers alone; application/json; charset=utf-8 is application/json. A body too large is 413, and the endpoint may stop reading it once it knows. A body that could not be read (empty where one is required, broken, or nested too deep) is 400. A body that was read but is a bare scalar is 422: it is well-formed, just not something an endpoint can take fields from.

Each refusal also carries a code, so a client never reads the message to tell them apart: UNSUPPORTED_MEDIA_TYPE for 415, REQUEST_BODY_TOO_LARGE for 413, and INVALID_REQUEST_BODY for 400 and for the scalar's 422. The scalar shares the unreadable bodies' code because, to a caller, both are a body the endpoint could not take fields from; the status still says which it was.

Depth sits with the unreadable bodies, not with the scalar, for a practical reason. Many JSON parsers enforce the depth limit themselves and stop there with an error, so an implementation cannot always say whether the rest of the body would have parsed. Putting depth on the 400 side means it gets the same answer however it is caught.

The depth bound is easy to get off by one. The bound is a maximum depth, so a document nested 64 levels deep is already one level past what is accepted; every implementation accepts a document nested 63 levels deep, and no deeper is promised.

The other clause that bites is the one API-1 states in general and this rule makes concrete: an endpoint whose body is optional is not an endpoint the gate skips. An absent body is fine, but a body that is present and malformed is refused like any other — the gate does not degrade "nothing to check" into "nothing checked".

Example

An endpoint whose body is optional still runs whatever is actually sent through the same gate as any other endpoint.

A scalar: read, but not a shape the gate can work with422 — refused
POST /api/flowdrop/workflows/{workflow_id}/playground/sessions

5
Well-formed on the outside, broken underneath400 — refused
POST /api/flowdrop/workflows/{workflow_id}/playground/sessions

{"name": "unterminated

Sending nothing at all to this same endpoint is still accepted — the gate's bounds apply to what is sent, not to whether something was sent.

Why

Recorded under OPEN-25, OPEN-49.

Rule identifiers are permanent and are never renumbered. Each implementation publishes its own standing against these rules; this specification does not.spec 1.0 · STORE-1 · changed in spec 1.1