GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Invalid JSON being logged for no good reason · Issue #1116 · googleapis/google-api-python-client

Invalid JSON being logged for no good reason #1116

New issue
Copy link
New issue
Copy link
Closed
#1117
Closed
Invalid JSON being logged for no good reason#1116
#1117
Copy link
Assignees
parthea
Labels
priority: p2Moderately-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.

Description

@kapilt
kapilt
opened on Dec 1, 2020
Issue body actions

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-client version: pip show google-api-python-client

Steps to reproduce

  1. 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.

Activity

  1. kapilt
    added 2 commits that reference this issue on Dec 1, 2020

    handle error on service not enabled - closes googleapis#1116

    This issue will close once commit 8f5b998 is merged into the 'master' branch.
    8f5b998

    fix: handle error on service not enabled - closes googleapis#1116

    This issue will close once commit 2f57f92 is merged into the 'master' branch.
    2f57f92
  2. yoshi-automation
    added
    triage meI really want to be triaged.
    on Dec 2, 2020
  3. parthea
    added
    type: bugError or flaw in code with unintended results or allowing sub-optimal usage patterns.
    on Dec 2, 2020
  4. parthea
    self-assigned this
    on Dec 2, 2020
  5. parthea
    added
    priority: p2Moderately-important priority. Fix may not be included in next release.
    and removed
    triage meI really want to be triaged.
    on Dec 2, 2020
  6. gcf-merge-on-green
    closed this as completedin #1117on Dec 2, 2020
  7. gcf-merge-on-green
    added a commit that references this issue on Dec 2, 2020

    fix: handle error on service not enabled (#1117)

    This issue will close once commit c691283 is merged into the 'main' branch.
    c691283
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

  • @parthea
    parthea

Labels

priority: p2Moderately-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.

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

    You are visitor 01402775 — GeezerVison does not store the pages you look up.
    Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.