Unexpected Content-Type when setting return_error_code and return_error_msg #707
Description
Describe the bug
I've combed through the documentation looking for an explanation or misconfiguration on my part, so my apologies if this is expected. I'm trying to implement this strategy:
Return the HTTP status code and error body of a single backend. No obfuscation at all. Forwards the error body and the status code of a single backend. Use return_error_code and return_error_msg together.
I have added the following configuration to my endpoint's backend, and I have added "return_error_msg": true
to my router configuration.
"extra_config": {
"backend/http": {
"return_error_code": true
}
}
I do indeed see the HTTP status code and error body of my backend returned after adding this configuration. However, the Content-Type
of the response is text/plain
for any non-2xx responses instead of application/json
like I would expect. For 2xx responses, Content-Type
is application/json
as expected.
My understanding is that the default output_encoding
is json
, and I do not override that anywhere. I've tried explicitly setting the output_encoding
to json
on the endpoint and setting the encoding
to json
in the endpoint's backend configuration, but so far I've had no luck in getting the content-type to return as application/json
.
Is this expected or a bug? Is there any way to force non-2xx responses to use application/json
when using return_error_code
and return_error_msg
?
Expected behavior
Both 2xx and non-2xx responses use Content-Type: application/json
when setting "return_error_code": true
and "return_error_msg": true
.
Thank you for reviewing!