OriginChain docs
examples · errors · 1 / 19

1. 400 - malformed JSON body

← Errors examples
what this error means

The HTTP request reached the engine, but the body bytes did not parse as JSON. The router rejects before any handler runs - no work was done, no rows were touched. The error code is invalid_json and the message points at the byte offset where the parser gave up.

what triggers it

A trailing comma after the last key in the JSON body. The closing } arrives where the parser expected another key.

POST /v1/tenants/:t/sql - invalid body
curl -X POST "https://$OC_HOST/v1/tenants/$OC_TENANT/sql" \
  -H "Authorization: Bearer $OC_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"sql": "SELECT 1",}'
the canonical response body
{
  "error": "invalid_json",
  "message": "trailing comma at byte offset 18",
  "retry": false
}
how to recover
  • Read the message - it tells you the byte offset where the parse failed.
  • Lint your payload through a JSON validator (or your language's stdlib JSON encoder) before sending.
  • If you're hand-constructing JSON in a shell with quoting tricks, switch to a heredoc or a temp file and --data-binary @body.json.
  • retry: false - the same bytes will fail the same way. Fix the body first.
common upstream causes
  • Trailing comma after the last field (JSON5 habit leaking into strict JSON).
  • Unterminated string - a missing closing " from shell-escape collisions.
  • Wrong Content-Type header (e.g. text/plain); the router treats those as invalid JSON.
  • Empty body on an endpoint that requires one - the parser sees EOF where it expected {.
  • String-templated payloads with unescaped quotes from user input.