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

Pass through error message and/or error description from response body #257

Open
1 task done
r2DoesInc opened this issue Jan 31, 2024 · 1 comment
Open
1 task done
Assignees
Labels
type:feature_request Feature request

Comments

@r2DoesInc
Copy link

Is there an existing issue for this?

  • I have searched the existing issues

Describe the problem to be solved

I have this setup as a default error handler on my k8s cluster, and it works great overall. My apis deployed on the cluster have a bit of an issue though.

When returning a 404 or something that this project is setup to respond for, my error content is ignored.

This turns my

{
    "error": "location_invalid",
    "message": "Given location either does not exist or is invalid."
}

Into

{
    "error": true,
    "code": "404",
    "message": "Not Found",
    "description": "The server can not find the requested page",
}

Suggest a solution

I propose modifying the error page to pull from the response body if it is provided

Something like

props.Message = page.Message()

props.Message =  string(ctx.Request.Body.Peek(Message))

I dont know go, so not sure if thats how it would be implemented.

This could be configured behind a bool for ALLOW_ERROR_MESSAGE_PASSTHROUGH which would default to false to maintain consistency with prior behavior.

Additional context

No response

@Ruakij
Copy link

Ruakij commented Apr 7, 2024

I was just looking into this too. I use Traefik as my Ingress, so maybe nginx handles things differently.
Unfortunately the error-middleware used to redirect to the error-page is a separate request and the original response is discarded. (see https://doc.traefik.io/traefik/middlewares/http/errorpages/)

There doesnt seem to be a way to only apply a middleware via a condition yet. So at this point i am unsure what options are left. A custom middleware should be able to do this i suppose.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type:feature_request Feature request
Projects
None yet
Development

No branches or pull requests

3 participants