-
Notifications
You must be signed in to change notification settings - Fork 345
Description
- OS: Ubuntu 20.04
- Python version: 3.8
- pip version: 20.0.2
google-authversion: 1.19.2
Steps to reproduce
- Arrange for gcloud to throw a warning. For example I'm suffering from this "Old version of cryptography" warning when using gsutil installed from snap GoogleCloudPlatform/gsutil#999
- Attempt to use ADC e.g.
credentials, project = google.auth.default() - Note that project always comes back at None even if
gcloud config set projectis correctly set - Root cause seems to be that in _cloud_sdk.py/get_project_id() the subprocess.check_output command merges stderr and stdout. So in the case that stderr is not empty and the subprocess does not fail, you might get badly formed JSON on which json.loads a few lines later chokes.
For example, my raw gcloud output is like:
/snap/google-cloud-sdk/165/lib/third_party/requests/init.py:83: RequestsDependencyWarning: Old version of cryptography ([1, 2, 3]) may cause slowdown.\n warnings.warn(warning, RequestsDependencyWarning)\n{\n "configuration": {\n "active_configuration": "default",\n "properties": {\n "core": {\n "account": "me@myemailaddress.com",\n "disable_usage_reporting": "False",\n "project": "my-test-project"\n },\n "deployment_manager": {\n "glob_imports": "True"\n }\n }\n },\n "credential": {\n "access_token".... etc etc.
Expected behaviour: non-fatal errors or warnings from gcloud should not corrupt the output and cause the project ID lookup to fail.