Skip to content

bug: POST /api/v1/quote returns 400 for invalid JSON body instead of 422 #4447

@ChainsQueen

Description

@ChainsQueen

Problem

Sending an invalid JSON body to the quote endpoint returns
400 instead of 422. The OpenAPI spec defines 422 as the
correct status code for unparseable JSON bodies.

Impact

Low — does not block core functionality but causes confusion
for SDK clients and integrators who follow the OpenAPI spec
to handle errors correctly.

To reproduce

  1. POST https://api.cow.fi/sepolia/api/v1/quote
  2. Header: Content-Type: application/json
  3. Body: {broken json
  4. Observe 400 Bad Request

Expected behaviour

Status: 422
Per OpenAPI spec:
422 → Unable to parse request body as valid JSON

Actual behaviour

Status: 400 Bad Request
Content-Type: text/plain; charset=utf-8
Body: Failed to parse the request body as JSON:
key must be a string at line 1 column 2

Screenshots/logs

See attached Postman screenshot showing the 400 response.

Image

services version/commit hash and environment

Version: v2.362.3-dirty
Environment: production (https://api.cow.fi/sepolia)

Additional context

Reference: https://docs.cow.fi/cow-protocol/reference/apis/orderbook

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingtrack:maintenancemaintenance track

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions