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

Use package grpcio-status to parse rich errors in trailing metadata. #99

Closed
busunkim96 opened this issue Oct 23, 2020 · 5 comments · Fixed by #286
Closed

Use package grpcio-status to parse rich errors in trailing metadata. #99

busunkim96 opened this issue Oct 23, 2020 · 5 comments · Fixed by #286
Assignees
Labels
type: feature request ‘Nice-to-have’ improvement, new feature or different behavior or design.

Comments

@busunkim96
Copy link
Contributor

Package: https://pypi.org/project/grpcio-status/

Example: https://github.com/grpc/grpc/blob/master/examples/python/errors/client.py#L37

We are from IAM Policy Analyzer team and we've recently found that the python client library does not seems to surface the details in the Error Status properly. We've tried using gcloud and it works as expected. The comparison is as below:

$ gcloud beta asset analyze-iam-policy --project=cai-playground
ERROR: (gcloud.beta.asset.analyze-iam-policy) INVALID_ARGUMENT: Some specified value(s) are invalid.
- '@type': type.googleapis.com/google.rpc.BadRequest
  fieldViolations:
  - description: At least one of resource selector, identity selector or access selector
      needs to  be specified.
    field: analysis_query
$ gcloud auth application-default login
$ python3
 from google.cloud import asset_v1p4beta1
 from google.cloud.asset_v1p4beta1 import AnalyzeIamPolicyRequest, IamPolicyAnalysisQuery
 parent="projects/cai-playground"
 client = asset_v1p4beta1.AssetServiceClient()
 response = client.analyze_iam_policy(request=AnalyzeIamPolicyRequest(analysis_query=IamPolicyAnalysisQuery(parent=parent)))

Traceback (most recent call last):
  File "/usr/local/google/home/aaronlichen/.local/lib/python3.8/site-packages/google/api_core/grpc_helpers.py", line 57, in error_remapped_callable
    return callable_(*args, **kwargs)
  File "/usr/local/google/home/aaronlichen/.local/lib/python3.8/site-packages/grpc/_channel.py", line 826, in __call__
    return _end_unary_response_blocking(state, call, False, None)
  File "/usr/local/google/home/aaronlichen/.local/lib/python3.8/site-packages/grpc/_channel.py", line 729, in _end_unary_response_blocking
    raise _InactiveRpcError(state)
grpc._channel._InactiveRpcError: <_InactiveRpcError of RPC that terminated with:
        status = StatusCode.INVALID_ARGUMENT
        details = "Some specified value(s) are invalid."
        debug_error_string = "{"created":"@1602024200.721639270","description":"Error received from peer ipv4:74.125.142.95:443","file":"src/core/lib/surface/call.cc","file_line":1061,"grpc_message":"Some specified value(s) are invalid.","grpc_status":3}"
@busunkim96 busunkim96 added type: bug Error or flaw in code with unintended results or allowing sub-optimal usage patterns. priority: p2 Moderately-important priority. Fix may not be included in next release. labels Oct 23, 2020
@tseaver
Copy link
Contributor

tseaver commented Dec 8, 2020

Where is the repository for grpcio-status? I'm reluctant to add a dependency on it without being able to report issues against it.

@busunkim96
Copy link
Contributor Author

It lives in the big grpc/grpc mono-repo. https://github.com/grpc/grpc/tree/master/src/python/grpcio_status

@yoshi-automation yoshi-automation added 🚨 This issue needs some love. and removed 🚨 This issue needs some love. labels Mar 8, 2021
@busunkim96 busunkim96 added type: feature request ‘Nice-to-have’ improvement, new feature or different behavior or design. and removed priority: p2 Moderately-important priority. Fix may not be included in next release. type: bug Error or flaw in code with unintended results or allowing sub-optimal usage patterns. labels Mar 12, 2021
@ocervell
Copy link

Any updates here ? Copying full requests in the browser API testing tool is a real pain for end-users, getting some error details would go a long way to make this library great !

@busunkim96
Copy link
Contributor Author

Hi @ocervell,

I believe this is on the roadmap for this quarter. @danoscarmike could you confirm?

@alexander-fenster
Copy link

We (@xiaozhenliu-gg5 and myself) plan to have interns work on the error parsing during the summer across all languages, and will likely start with Python. Please leave this to us so we don't have two concurrent fixes coming :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: feature request ‘Nice-to-have’ improvement, new feature or different behavior or design.
Projects
None yet
5 participants