-
Notifications
You must be signed in to change notification settings - Fork 2.5k
Closed
Labels
priority: p2Moderately-important priority. Fix may not be included in next release.Moderately-important priority. Fix may not be included in next release.type: bugError or flaw in code with unintended results or allowing sub-optimal usage patterns.Error or flaw in code with unintended results or allowing sub-optimal usage patterns.
Description
Environment details
- OS: Linux
- Python: 3.9
- api client Version: 1.12.8
- OS type and version:
- Python version:
python --version - pip version:
pip --version google-api-python-clientversion:pip show google-api-python-client
Steps to reproduce
- use google api client against a service thats not been enabled in a project, watch it throw an invalid message
2020-12-01 11:35:58,296: googleapiclient.http:WARNING Invalid JSON content from response: b'{\n "error": {\n "code": 403,\n "message": "Cloud Functions API has not been used in project 683429142524 before
or it is disabled. Enable it by visiting https://console.developers.google.com/apis/api/cloudfunctions.googleapis.com/overview?project=683429142524 then retry. If you enabled this API recently, wait a few minutes
for the action to propagate to our systems and retry.",\n "status": "PERMISSION_DENIED",\n "details": [\n {\n "@type": "type.googleapis.com/google.rpc.Help",\n "links": [\n {\n
"description": "Google developers console API activation",\n "url": "https://console.developers.google.com/apis/api/cloudfunctions.googleapis.com/overview?project=683429142524"\n }\
n ]\n },\n {\n "@type": "type.googleapis.com/google.rpc.ErrorInfo",\n "reason": "SERVICE_DISABLED",\n "domain": "googleapis.com",\n "metadata": {\n "service":
"cloudfunctions.googleapis.com",\n "consumer": "projects/683429142524"\n }\n }\n ]\n }\n}\n'
Solution
Either stop error sniffing or expand it to additional valid use scenarios, in this case the particular payload was
{'error': {'code': 403,
'details': [{'@type': 'type.googleapis.com/google.rpc.Help',
'links': [{'description': 'Google developers console '
'API activation',
'url': 'https://console.developers.google.com/apis/api/cloudfunctions.googleapis.com/overview?project=926761696986'}]},
{'@type': 'type.googleapis.com/google.rpc.ErrorInfo',
'domain': 'googleapis.com',
'metadata': {'consumer': 'projects/redacted',
'service': 'cloudfunctions.googleapis.com'},
'reason': 'SERVICE_DISABLED'}],
'message': 'Cloud Functions API has not been used in project '
'926761696986 before or it is disabled. Enable it by '
'visiting '
'https://console.developers.google.com/apis/api/cloudfunctions.googleapis.com/overview?project=redacted '
'then retry. If you enabled this API recently, wait a '
'few minutes for the action to propagate to our systems '
'and retry.',
'status': 'PERMISSION_DENIED'}} there's a bunch of well known key sniffing in http.py on error which doesn't properly look at message or status and should be updated to do the same to avoid throwing an Invalid JSON message on perfectly valid json.
Metadata
Metadata
Assignees
Labels
priority: p2Moderately-important priority. Fix may not be included in next release.Moderately-important priority. Fix may not be included in next release.type: bugError or flaw in code with unintended results or allowing sub-optimal usage patterns.Error or flaw in code with unintended results or allowing sub-optimal usage patterns.