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

Fix wrong status code if context.abort has been called #43

Merged
merged 3 commits into from
Aug 15, 2023

Conversation

thangtp
Copy link
Contributor

@thangtp thangtp commented Aug 11, 2023

When context.abort is invoked prior to the interceptor being reached, the status code specified in context.abort should be used, taking precedence over status_on_unknown_exception.

Example:

Given the use of the following interceptor:

ExceptionToStatusInterceptor(status_on_unknown_exception=grpc.StatusCode.INTERNAL)

If context.abort is implemented somewhere in the service as:

context.abort(grpc.StatusCode.RESOURCE_EXHAUSTED, 'resource exhausted')

Expected Behavior:

The service should return an error with the status code set to grpc.StatusCode.RESOURCE_EXHAUSTED.

@d5h d5h merged commit 25edf03 into d5h-foss:master Aug 15, 2023
17 checks passed
@d5h
Copy link
Collaborator

d5h commented Aug 15, 2023

Awesome! Thank you for this contribution @thangtp! Much appreciated. The release should go out shortly.

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

Successfully merging this pull request may close these issues.

2 participants