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

[Spanner] authentication issues should result in a user error #4

Closed
jeanbza opened this issue Nov 27, 2019 · 11 comments
Closed

[Spanner] authentication issues should result in a user error #4

jeanbza opened this issue Nov 27, 2019 · 11 comments
Assignees
Labels
api: spanner Issues related to the googleapis/python-spanner API. priority: p2 Moderately-important priority. Fix may not be included in next release. 🚨 This issue needs some love. type: bug Error or flaw in code with unintended results or allowing sub-optimal usage patterns.

Comments

@jeanbza
Copy link
Member

jeanbza commented Nov 27, 2019

  1. Copy paste code from https://cloud.google.com/spanner/docs/getting-started/python/
  2. Run

... it hangs forever

  1. Waste Spend hour struggling to figure out what is happening.

  2. Figure out how to turn on http logging with,

    import logging
    
    logging.basicConfig(level=logging.DEBUG)
    
  3. See:

    DEBUG:google.auth.transport.requests:Making request: POST https://oauth2.googleapis.com/token
    DEBUG:urllib3.connectionpool:https://oauth2.googleapis.com:443 "POST /token HTTP/1.1" 400 None
    ERROR:grpc._plugin_wrapping:AuthMetadataPluginCallback "<google.auth.transport.grpc.AuthMetadataPlugin object at 0x10d79d4a8>" raised exception!
    Traceback (most recent call last):
    File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/grpc/_plugin_wrapping.py", line 79, in __call__
        callback_state, callback))
    File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/google/auth/transport/grpc.py", line 77, in __call__
        callback(self._get_authorization_headers(context), None)
    File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/google/auth/transport/grpc.py", line 65, in _get_authorization_headers
        headers)
    File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/google/auth/credentials.py", line 122, in before_request
        self.refresh(request)
    File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/google/oauth2/service_account.py", line 322, in refresh
        request, self._token_uri, assertion)
    File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/google/oauth2/_client.py", line 145, in jwt_grant
        response_data = _token_endpoint_request(request, token_uri, body)
    File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/google/oauth2/_client.py", line 111, in _token_endpoint_request
        _handle_error_response(response_body)
    File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/google/oauth2/_client.py", line 61, in _handle_error_response
        error_details, response_body)
    google.auth.exceptions.RefreshError: ('invalid_grant: Not a valid email or user ID.', '{\n  "error": "invalid_grant",\n  "error_description": "Not a valid email or user ID."\n}')
    DEBUG:google.api_core.retry:Retrying due to 503 Getting metadata from plugin failed with error: ('invalid_grant: Not a valid email or user ID.', '{\n  "error": "invalid_grant",\n  "error_description": "Not a valid email or user ID."\n}'), sleeping 1.3s ...
    

This is an error that will never resolve. We should surface it to the user immediately.

Also: I have no idea why this is a 503 UNAVAILABLE. Why would it not be a 400 BAD REQUEST or 401 UNAUTHORIZED??

@jeanbza
Copy link
Member Author

jeanbza commented Nov 27, 2019

cc @broady

@mf2199 mf2199 changed the title authentication issues should result in a user error [Spanner] authentication issues should result in a user error Nov 28, 2019
@HemangChothani
Copy link
Contributor

found the related issue in java also 3573

@HemangChothani
Copy link
Contributor

@jadekler I tried to figure out why it throws 503, as per my research urllib3 throws 400 but the grpc convert into the INTERNAL error code and that is 13, may be the suspected line of code and then rest is done in google-api-core.

@jeanbza
Copy link
Member Author

jeanbza commented Dec 3, 2019

@HemangChothani Is INTERNAL a retried code?

@HemangChothani
Copy link
Contributor

@jadekler I think yes, due to that i have got the error multiple times and by default deadline is 3600s. So due to this foor loop which is in api_core/retry.py and long deadline it looks like goes into the infinite loop or it hangs.

@broady
Copy link

broady commented Dec 4, 2019 via email

@jeanbza
Copy link
Member Author

jeanbza commented Dec 4, 2019

@jadekler I think yes, due to that i have got the error multiple times and by default deadline is 3600s. So due to this foor loop which is in api_core/retry.py and long deadline it looks like goes into the infinite loop or it hangs.

Gotcha. We probably shouldn't retry INTERNAL (https://aip.dev/194).

Looks like it's a 400 at one point, which indicates some broken plumbing
where it didn't surface properly?

Sounds right.

@HemangChothani
Copy link
Contributor

Another similar issue 7199 has been found, so can we close one of them? Because it is a kind of duplicate issue.

@crwilcox crwilcox transferred this issue from googleapis/google-cloud-python Jan 31, 2020
@product-auto-label product-auto-label bot added the api: spanner Issues related to the googleapis/python-spanner API. label Jan 31, 2020
@yoshi-automation yoshi-automation added triage me I really want to be triaged. 🚨 This issue needs some love. labels Feb 3, 2020
@busunkim96 busunkim96 added 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. and removed 🚨 This issue needs some love. triage me I really want to be triaged. labels Feb 4, 2020
@yoshi-automation yoshi-automation added 🚨 This issue needs some love. and removed 🚨 This issue needs some love. labels May 4, 2020
@yoshi-automation yoshi-automation added the 🚨 This issue needs some love. label May 25, 2020
@larkee
Copy link
Contributor

larkee commented Jun 19, 2020

Not sure how to progress here. Seems like an issue in another library. Need to investigate further.

@larkee larkee removed the 🚨 This issue needs some love. label Jun 19, 2020
@yoshi-automation yoshi-automation added the 🚨 This issue needs some love. label Jun 19, 2020
@larkee larkee self-assigned this Jun 26, 2020
@larkee
Copy link
Contributor

larkee commented Jun 26, 2020

Looks like it's a 400 at one point, which indicates some broken plumbing where it didn't surface properly?

The auth library does not pass through the status error code through to gRPC. However, gRPC would replace it with INTERNAL regardless. See status conversion.

It is still unclear as to why the client receives an UNAVAILABLE error.

@larkee
Copy link
Contributor

larkee commented Jul 3, 2020

This is not an issue with the client library, but with its dependencies. I have filed an issue with grpc and will monitor its progress. Since there is nothing to be done in the client library, I am closing this issue.

@larkee larkee closed this as completed Jul 3, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api: spanner Issues related to the googleapis/python-spanner API. priority: p2 Moderately-important priority. Fix may not be included in next release. 🚨 This issue needs some love. type: bug Error or flaw in code with unintended results or allowing sub-optimal usage patterns.
Projects
None yet
Development

No branches or pull requests

6 participants