cannot use multiple different error handlers in one gateway binary #1143
Closed
Description
Fill in the following sections with explanations of what's gone wrong.
Steps you follow to reproduce the error:
- Create ServeMux without a custom error handler. Register it to handle prefix "/v1"
- Create a ServeMux with a custom error handler using
runtime.WithProtoErrorHandler
. Register it to handle prefix "/v2". - Make calls resulting in errors to a mix of v1 and v2 endpoints.
Observe that the v2 error handler runs for:
- errors returned from the backends on both the v1 and v2 endpoints
- errors returned from within runtime.ServeMux code (e.g. Unimplemented on unknown URIs) on the v2 endpoints
Errors from within runtime.ServeMux code (like unknown URIs) under v1 result in unexpected use of OtherErrorHandler
errors.
What did you expect to happen instead:
- v1 endpoints use the default error handler
- v2 endpoints use the configured custom error handler.
What's your theory on why it isn't working:
- The
WithProtoErrorHandler
option overwrites a global handler HTTPError and configures the global OtherErrorHandler to return "unexpected use" errors:Line 169 in 9aff355
- Generated gateway handler code calls the global HTTPError regardless of the protoErrorHandler configured on the current ServeMux instance:
- Without a configured protoErrorHandler, ServeMux falls back to the global OtherErrorHandler (which has been overwritten if any mux in the process has a protoErrorHandler configured).
An initial patch to fix this issue can be seen here: master...paxosglobal:per-mux-error-handler
However, since this does change the generated code to rely on the updated runtime code, I'd appreciate guidance on the process for handling/merging this kind of breaking change.
Metadata
Assignees
Labels
No labels