Open Source API Gateway

500 Internal Server Error: Internal Route Response Failed

Membrane API Gateway returns 500 Internal Server Error with this page when it fails to run the response handling of the internal APIs a request had passed through via internal:// targets. This is rare and usually indicates a bug in Membrane or an unexpected internal state.

The Error Response

The response contains the status 500 Internal Server Error, the problem type https://membrane-api.io/problems/internal and a link to this page. The error occurs in the response flow. The type internal means that the gateway could not complete the processing of the response. In production mode, the title is replaced by Internal Server Error and the details are left out.

What Happens on the Way Back

When a request is forwarded to another API with an internal:// target, Membrane remembers the plugins of that internal API. When the response comes back, it runs their response handling. Exceptions in those plugins are normally caught and reported under the plugin's own URL. This page is only used when running the response handling itself fails. No concrete trigger is known, so the causes below are described in general terms.

Common Causes

An Exchange Property Was Overwritten

Membrane keeps the internal API's plugins for the way back in the exchange property membrane.routing.back.interceptors. If a script or plugin overwrites this property with a value that is not a list, the response handling fails.

Another Unexpected Error

Another unexpected exception in the internal route's response handling. It is logged as Could not invoke response handler for internal route. with the stack trace.

How to Fix It

  1. Operator: make sure no script or plugin writes the exchange property membrane.routing.back.interceptors.
  2. Otherwise, enable development mode, or in production look up the log key of the response in the gateway log, and report the stack trace with the configuration of both APIs on GitHub Issues.

For routing problems on the way in, see internal/internal-routing/request.

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 ---. The response then only contains a log key. Search the gateway log for this key to find the exception.

Related Documentation

Configuration reference:

← All Membrane error messages

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