You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
stevenj opened this issue
Jan 31, 2025
· 1 comment
Labels
A-http1Area: HTTP/1 specific.A-serverArea: server.C-featureCategory: feature. This is adding a new feature.E-mediumEffort: medium. Some knowledge of how hyper internal works would be useful.
When hyper gets a header with 0x7f in it, it generates a 400 response with no content type specified and no body.
The problem is, our OpenApi specification for our service defines a different response for 400, which matches the behavior of our services endpoints.
However, OpenAPI 3.0.x only allows you to define multiple response types for the same response code IF and ONLY IF they ALL have a content type. You can only have one response schema per distinct content type.
This breaks our CI. Our automated tests trigger hypers default 400 response. The response does not conform with our OpenAPI spec, so the breakage is 100% correct. It's not possible to define an OpenAPI spec which includes both hypers 400 response, and our designed 400 response.
The upshot is, Hyper has squatted on 400 and we can't re-define it, if we want a valid OpenAPI specification, and a service which 100% reflects it.
So our choices if we want to use 400 and have a valid spec is return no information in the error, this is not possible for us.
This has meant we can't use 400 at all.
Interestingly, hyper internally comments the response can be any 4xx, but the trait that would be needed to customize the Server struct is not public outside the crate, so it has proven impossible to get Hyper to have different behavior than an empty 400 with no content type.
We have spent a lot of time trying to solve this, but have we missed something and it is possible to redefine what hyper will return for 400?
The text was updated successfully, but these errors were encountered:
seanmonstar
added
A-server
Area: server.
C-feature
Category: feature. This is adding a new feature.
E-medium
Effort: medium. Some knowledge of how hyper internal works would be useful.
A-http1
Area: HTTP/1 specific.
and removed
C-bug
Category: bug. Something is wrong. This is bad!
labels
Feb 6, 2025
I can see why someone would need to modify those automatic responses. I'd be fine with adding a mechanism to do so. Care would be required that it not leak too many internal details, so we can refactor things at any time and not worry about breaking this public API.
Would you be interested in exploring that with those constraints?
seanmonstar
changed the title
Hypers default 400 response can not be changed and breaks OpenAPI 3.0.x schema tests.
Allow customizing the server's default error response
Feb 6, 2025
A-http1Area: HTTP/1 specific.A-serverArea: server.C-featureCategory: feature. This is adding a new feature.E-mediumEffort: medium. Some knowledge of how hyper internal works would be useful.
Version
1.6.0
Platform
Linux x86-64
Description
When hyper gets a header with 0x7f in it, it generates a 400 response with no content type specified and no body.
The problem is, our OpenApi specification for our service defines a different response for 400, which matches the behavior of our services endpoints.
However, OpenAPI 3.0.x only allows you to define multiple response types for the same response code IF and ONLY IF they ALL have a content type. You can only have one response schema per distinct content type.
This breaks our CI. Our automated tests trigger hypers default 400 response. The response does not conform with our OpenAPI spec, so the breakage is 100% correct. It's not possible to define an OpenAPI spec which includes both hypers 400 response, and our designed 400 response.
The upshot is, Hyper has squatted on 400 and we can't re-define it, if we want a valid OpenAPI specification, and a service which 100% reflects it.
So our choices if we want to use 400 and have a valid spec is return no information in the error, this is not possible for us.
This has meant we can't use 400 at all.
Interestingly, hyper internally comments the response can be any 4xx, but the trait that would be needed to customize the
Server
struct is not public outside the crate, so it has proven impossible to get Hyper to have different behavior than an empty 400 with no content type.We have spent a lot of time trying to solve this, but have we missed something and it is possible to redefine what hyper will return for 400?
The text was updated successfully, but these errors were encountered: