Open Source API Gateway

500 Internal Server Error: Error During OpenAPI Response Validation

Membrane API Gateway returns 500 Internal Server Error when the OpenAPI validator hits an unexpected error while validating the backend response against the OpenAPI document. This is not a validation result about the response. It indicates an internal error in Membrane, or an OpenAPI construct the validator cannot handle.

The Error Response

The response contains the status 500 Internal Server Error, the title User error., the detail Message could not be validated against OpenAPI cause of an error during validation. Please check the OpenAPI with title Fruit Shop API. with the title of the document, the exception, the problem type https://membrane-api.io/problems/user and a link to this page. The error happens in the response flow, so the client receives 500. In production mode, the title is replaced by Internal Server Error and the detail by a log key.

If the backend response violates the OpenAPI document, Membrane answers with an OpenAPI message validation failed error instead, which lists the violations.

What the OpenAPI Validator Does

For an API deployed from an OpenAPI document with validateResponses on, the validator checks the status, headers and body of each backend response against the response definitions of the operation. This error means that the check itself failed.

Common Causes

An Internal Error in the Validator

An unusual combination of response and OpenAPI document triggers an error in the validator, for example a NullPointerException. This usually indicates a bug in Membrane.

An Unsupported OpenAPI Construct

The response definitions use a construct that the validator does not support.

How to Fix It

  1. Look up the error in the log. Membrane logs the stack trace at error level. In production mode, search the log for the key from the response.
  2. Try to find the part of the response definition that triggers the error.
  3. Report the problem on GitHub Issues with the stack trace, the relevant part of the OpenAPI document and a sample response.

As a temporary workaround, switch off response validation for the document:

api:
port: 2000
openapi:
- location: fruitshop-api.yml
validateResponses: false
api:
  port: 2000
  openapi:
    - location: fruitshop-api.yml
      validateResponses: false

Hide Details in Production

By default, Membrane runs in development mode and adds details to error responses that help you find the problem. These details may reveal information about your setup. In production, turn them off:

configuration:
production: true
configuration:
  production: true

Add the configuration document to your apis.yaml and separate it from the APIs with ---.

Related Documentation

Configuration reference:

Tutorials with runnable examples:

← All Membrane error messages

Still stuck? See the troubleshooting guide or ask on GitHub Issues. For commercial support, contact info@predic8.de.