Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[gateway] API gateway is not forwarding HTTP/1.1 error code statustext in response header #2381

Comments

@kawaiipantsu
Copy link

commented Jun 18, 2019

I have created a small test setup for this issue so it's easier to follow. In my test scenario i have a Apache/php endpoint microservice and a simple java-script Ajax frontend who calls it via the API gateway. We use HTTP error codes+status text to create a fast error reporting back to the client/frontend so that we don't have to send any body content. So if the microservice is fine it will return JSON body content, if it fails it will only return a response header with a HTTP error code and custom error text.

Expected Behavior

Let's say we are looking up customer data but the customer ID was not found, then we use code 404 but we have multiple use cases for 404 so we also rely on the status text for that 404.

So etc if Customer ID was not found we would return the following from PHP.
header("HTTP/1.1 404 Customer ID not found");

So etc if Customer Email was not found we would return the following from PHP.
header("HTTP/1.1 404 Customer E-Mail not found");

This works fine if we are talking directly to the endpoint via our frontend java-script calls.
We will receive both status code as 404 and status text as the custom text.

Current Behavior

What we see when going though the Gravitee API gateway is that it somehow sanitizes or changes the response header error message.

We are sending: HTTP/1.1 404 Customer ID not found
API Gateway is sending: HTTP/1.1 404 Not Found

This will cripple our frontend as we now can't distinct between error messages for when queries are not found etc.

Possible Solution

Have a toggle switch to disable "sanitation" of HTTP error codes ?

Steps to Reproduce (for bugs)

Sadly i can't provide live examples as our gateway is on the internal network.

But a simple way to reproduce is to setup a Apache/php endpoint with one file and one line in it.
header("HTTP/1.1 404 My custom error text");

  1. Call it directly to see the response error is sent correctly you recieve both errorcode + errortext
  2. Call it though the api gateway to see the errortext is no longer included but the errorcode is still correct

Context

It affect us in the way that we can't create stateless fast error replies via our endpoints with custom error messages. We don't want overhead that's why we don't send body content when doing error reporting, but you are still allowed to change the HTTP/1.1 custom error text. This is a normal use case scenario. So it's unfortunately that the API gateway is stopping this behavior.

Your Environment

It's running in a Openshift environment.
Using your docker images, default config, all working as it should.

  • Version used: 1.26.1 (build: 525) revision#67427b86f3942de150851b56ebc7d62e8913f305
  • Browser Name and version: Any browser for frontend
  • Operating System and version:
brasseld added a commit to gravitee-io/gravitee-gateway-api that referenced this issue Jul 18, 2019
brasseld added a commit to gravitee-io/gravitee-gateway that referenced this issue Jul 18, 2019
@brasseld brasseld changed the title Gravitee API gateway is not forwarding HTTP/1.1 error code statustext in response header [gateway] API gateway is not forwarding HTTP/1.1 error code statustext in response header Jul 18, 2019
@brasseld brasseld self-assigned this Jul 18, 2019
@brasseld brasseld added this to the APIM - 1.29.0 milestone Jul 18, 2019
brasseld added a commit to gravitee-io/gravitee-gateway that referenced this issue Jul 18, 2019
NicolasGeraud added a commit to gravitee-io/gravitee-gateway-api that referenced this issue Aug 26, 2019
NicolasGeraud added a commit to gravitee-io/gravitee-gateway that referenced this issue Aug 26, 2019
NicolasGeraud added a commit to gravitee-io/gravitee-gateway-api that referenced this issue Aug 26, 2019
NicolasGeraud added a commit to gravitee-io/gravitee-gateway that referenced this issue Aug 26, 2019
NicolasGeraud added a commit to gravitee-io/gravitee-gateway that referenced this issue Aug 26, 2019
NicolasGeraud added a commit to gravitee-io/gravitee-common that referenced this issue Aug 26, 2019
@NicolasGeraud NicolasGeraud reopened this Aug 26, 2019
NicolasGeraud added a commit to gravitee-io/gravitee-gateway-api that referenced this issue Aug 27, 2019
NicolasGeraud added a commit to gravitee-io/gravitee-gateway-api that referenced this issue Aug 27, 2019
NicolasGeraud added a commit to gravitee-io/gravitee-gateway-api that referenced this issue Aug 27, 2019
NicolasGeraud added a commit to gravitee-io/gravitee-gateway that referenced this issue Aug 27, 2019
NicolasGeraud added a commit to gravitee-io/gravitee-gateway that referenced this issue Aug 27, 2019
NicolasGeraud added a commit to gravitee-io/gravitee-gateway that referenced this issue Sep 3, 2019
brasseld added a commit to gravitee-io/gravitee-gateway that referenced this issue Sep 4, 2019
brasseld added a commit to gravitee-io/gravitee-gateway that referenced this issue Sep 4, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
API Management
Awaiting triage
4 participants
You can’t perform that action at this time.