Open Source API Gateway

500 Internal Server Error: Could Not Create URI

Membrane API Gateway returns 500 Internal Server Error with the detail Could not create uri when the webServer plugin cannot parse the request URI. The same applies to components built on it: adminConsole and the login dialogs of login and oauth2authserver.

The Error Response

The response contains the status 500 Internal Server Error, the detail Could not create uri, the problem type https://membrane-api.io/problems/internal and a link to this page. In development mode, it also contains the message of the URI parser, including the position of the bad character. Although the type is internal, the cause is usually the request URI sent by the client. In production mode, the title is replaced by Internal Server Error and the details are left out.

Where the URI Comes From

The plugin parses the destination of the exchange to find the requested document. In an API without a target, the destination is the raw request URI that the client sent.

Common Causes

Illegal Characters in the Path or Query

The request path or query contains characters that are not allowed in a URI and are not percent-encoded, for example |, {, }, ^, " or <. Membrane's URI parser rejects them unless illegal characters are explicitly allowed.

A URI Syntax Error

The request line contains a malformed percent-escape, such as %G1, or another URI syntax error.

How to Fix It

  1. Client side: percent-encode special characters in the path and query, for example | as %7C.
  2. Gateway operator: if clients cannot be changed and such characters must be accepted, allow them in the global configuration:
configuration:
uriFactory:
allowIllegalCharacters: true
configuration:
  uriFactory:
    allowIllegalCharacters: true

This setting weakens URI validation for all APIs of the gateway. Use it only when you cannot fix the clients.

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 title then reads Internal Server Error, and the details and the link to this page are left out. If the response contains a log key, search the gateway log for it to find the full error message.

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.