googleapis / python-api-core

https://googleapis.dev/python/google-api-core/latest
Apache License 2.0
112 stars 82 forks source link

AttributeError: 'NoneType' object has no attribute 'from_call' #659

Open parthea opened 1 month ago

parthea commented 1 month ago

In exceptions.py, if grpcio-status is not installed, rpc_status is set to None

https://github.com/googleapis/python-api-core/blob/d96eb5cdd8120bfec97d62b09512c6fecc325be8/google/api_core/exceptions.py#L31-L43

In _parse_grpc_error_details, when rpc_status is None, this leads to AttributeError: 'NoneType' object has no attribute 'from_call' https://github.com/googleapis/python-api-core/blob/d96eb5cdd8120bfec97d62b09512c6fecc325be8/google/api_core/exceptions.py#L562-L566

We should add a check to make sure rpc_status is not None before calling rpc_status.from_call(rpc_exc)

LostInCode404 commented 1 month ago

I faced this issue when I was making API calls to gemini-1.5-pro model using langchain-google-genai module. Because of this issue, I could not initially understand the actual cause.

After reading this thread, I installed grpcio-status, after which I could see the actual error: 429 Resource has been exhausted (e.g. check quota).