Skip to content

openapi: request validation fails for application/x-www-form-urlencoded content type #255

@intel352

Description

@intel352

When validation.request: true is set on the openapi module, request validation for operations with application/x-www-form-urlencoded content type fails with:

{"error":"request validation failed","errors":["request body contains invalid JSON: invalid character 'B' looking for beginning of value"]}

The validator attempts to parse the form-encoded body as JSON, ignoring the Content-Type header and the spec's declared content type.

Reproduce:

  1. Define an operation with application/x-www-form-urlencoded request body in the spec
  2. Enable validation.request: true on the openapi module
  3. Send a form-encoded POST request to the operation's path
  4. Observe: validation rejects the request with "invalid JSON" error
  5. Expected: validation should parse and validate form-encoded bodies correctly, or skip validation for non-JSON content types

Workaround: Remove requestBody from the spec for form-encoded operations. The pipeline can still parse the body via step.request_parse with parse_body: true.

Spec example:

/webhook:
  post:
    operationId: receiveWebhook
    x-pipeline: handle-webhook
    requestBody:
      required: true
      content:
        application/x-www-form-urlencoded:
          schema:
            type: object
            properties:
              Body:
                type: string
              From:
                type: string

Metadata

Metadata

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions