-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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
Incorrect 502 status code of downstream service when response prematurely closed with 403 #1685
Comments
Hi Guntars! I agree, overriding of the status is not good. To be successful in fixing your problem, you need to collaborate more and develop your case. Why did you clear the log screenshot by white boxes?
Sorry, don't understand, what does this small screenshot mean? 502 status... 🆗 Possible solutionI suggest you to try the connection by OPTIONS request, first. It should return the auth-result. First step,Could you show us that client can establish (un)successful connection please? |
It is very abstract. Could you upload your solution to GitHub please, and share a link? And, do you have a draft solution to fix the problem of status overriding? |
Hi, I have updated the issue description. I see now what did you mean about streaming, it would be better if streaming option would be available. Because the downstream service responds quickly, but the file gets stuck in Ocelot till it is cached. So simple RBAC check could take resources instead of just returning error to client. This is maybe a seperate issue #695 Here is example configuration of ocelot {
"SwaggerKey": "eeeee",
"UpstreamPathTemplate": "/eeeee{everything}",
"UpstreamHttpMethod": [
"Get",
"Post",
"Put",
"Delete"
],
"DownstreamPathTemplate": "/eeeee{everything}",
"DownstreamScheme": "http",
"DownstreamHostAndPorts": [
{
"Host": "localhost",
"Port": 5002
}
]
}
Yes it could be correct response from Ocelot, but this means that downstream services cannot respond with non-200 status code, which makes harder to seperate micro services and api. This could be one of behaviours, but changing status code to downstream service should be an option. Also there is question - should 502 be only responsible for status codes 5xx from downsteream services? |
I don't care about streaming feature now because it is absolutely different feature. If you wish, continue discussion in appropriate issue thread please.
No, not for all. Current error mapper produces 502 in case of any connection errors: ErrorsToHttpStatusCodeMapper
Let's focus on the problem of status changing...
What solution is the best for you? |
Expected Behavior
Ocelot service
sends large file in POST →Downstream service
Returns whatever status code that Downstream service is replying.
Actual Behavior
If Downstream service does not accept the request and Ocelot is still sending the file, error occurs which results in Ocelot service status code 502, which is not what Downstream service is reporting.
Downstream service has its own Role based authorization in place

Downstream service always responds with 403 - Forbidden.

But Ocelot always responds with 502, because Downstream service RBAC returns 403 faster than request response
Steps to Reproduce the Problem
Specifications
The text was updated successfully, but these errors were encountered: