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

With v2 we should be able to detect real NotFound responses from gRPC service NotFound responses #1513

Closed
octo47 opened this issue Jul 9, 2020 · 5 comments

Comments

@octo47
Copy link
Contributor

octo47 commented Jul 9, 2020

🚀 Feature

With new unified error handler in v2 it is now not possible to detect if grpc-gateway has no uri registered or gRPC method returned real NotFound.

Proposal:
Add option grpcgwruntime.WithNotFoundHandler(errorHandler) so user can handle code correctly.

Current Behaviour is misleading and can cause issues:

  • Code returns NotFound which may clash with gRPC method returning NotFound
  • In replacement of MethodNotAllowed gRPC gateway returns codes.Unimplemented which in turn converted to a different http status code: 501 instead of 405
@octo47 octo47 changed the title With v2 we should be able to detect non-existent request from real gRPC NotFound response With v2 we should be able to detect real NotFound responses from real gRPC NotFound response Jul 9, 2020
@octo47 octo47 changed the title With v2 we should be able to detect real NotFound responses from real gRPC NotFound response With v2 we should be able to detect real NotFound responses from gRPC service NotFound response Jul 9, 2020
@octo47 octo47 changed the title With v2 we should be able to detect real NotFound responses from gRPC service NotFound response With v2 we should be able to detect real NotFound responses from gRPC service NotFound responses Jul 9, 2020
@johanbrandhorst
Copy link
Collaborator

This sounds like a good idea, I did wrestle with the issue of how to represent nonexistent URIs in the new error handling, and I think it makes sense to split it out of the existing handling altogether. Another thing that v1 did is differentiate between ErrUnknownURI and ErrMethodNotAllowed (e.g. sending GET to a POST endpoint). We might want to weave that into this new handler too, maybe we should make it more generic, how about WithHTTPErrorHandler or something that makes it obvious that it is pre any gRPC concerns?

CC @jhump who I know had some comments on the new error handling in v2 as well.

@octo47
Copy link
Contributor Author

octo47 commented Jul 10, 2020

@johanbrandhorst
Thanks for commenting!

Right, WithHTTPErrorHandler should be event better and cleaner way to handle pre-gRPC errors!

@johanbrandhorst
Copy link
Collaborator

Sounds good, what can I do to help you contribute this change? I would start looking at how the existing error handler is defined and used which should be easy enough to adapt to this new handler. We'll also need to update the v2 migration guide, which already has a section on error handling.

@octo47
Copy link
Contributor Author

octo47 commented Jul 10, 2020

I believe I can come up with PR in a few days and evaluate it on our codebase to see how it may fit.
Thanks for quick response!

@johanbrandhorst
Copy link
Collaborator

Fixed with #1517

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

No branches or pull requests

2 participants