Membrane API Gateway returns 500 Internal Server Error with the title XML Error when the xmlContentFilter plugin fails while removing XML nodes from a message in the request or response flow.
The response contains the status 500 Internal Server Error, the title XML Error, the problem type https://membrane-api.io/problems/internal and a link to this page. The type internal means that the gateway could not complete the processing of the message. In production mode, the title is replaced by Internal Server Error and the details are left out.
The xmlContentFilter plugin removes all nodes that its xPath expression selects from an XML message, for example to strip internal information from responses. A body that is not well-formed XML does not lead to this error: it is passed on unchanged.
The xPath selects nodes without a parent element, such as attributes (//@id) or the document node (/). Removing them fails. Only elements and other child nodes can be removed.
The XPath expression fails when it is evaluated, for example because it uses a function or namespace prefix that is not available.
The message body cannot be read or decoded, for example because the Content-Encoding is wrong or the sender aborted the transfer.
The modified document cannot be serialized again. This is rare.
The same link also appears when the xmlContentFilter plugin throws an exception that it does not turn into an error response itself. Membrane then aborts the exchange with 500 Internal Server Error, and the detail reads Aborting! Exception caused in xml-content-filter during … flow. with the request URI and the flow. Membrane logs every occurrence with the full stack trace. Unless the exception points to your configuration or to the message content, this usually indicates a bug in Membrane.
Make xPath select elements only. This filter removes all stacktrace elements from responses, regardless of their namespace:
api:
port: 2000
flow:
- response:
- xmlContentFilter:
xPath: "//*[local-name()='stacktrace']"
target:
url: https://api.predic8.de
api:
port: 2000
flow:
- response:
- xmlContentFilter:
xPath: "//*[local-name()='stacktrace']"
target:
url: https://api.predic8.de
Content-Encoding and whether the connection was interrupted.error level. If the causes above do not explain it, report the problem with the stack trace on GitHub Issues.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: trueconfiguration: 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.
If the plugin is nested inside a request, response or abort element and fails with an unexpected exception there, the exception message, the stack trace and the link to this page are currently sent even in production mode. Fix the failing plugin rather than relying on production mode to hide them.
Configuration reference:
Still stuck? See the troubleshooting guide or ask on GitHub Issues. For commercial support, contact info@predic8.de.