Skip to content

details missing in googleapiclient.errors.HttpError #382

@pdknsk

Description

@pdknsk

Run some code that makes an invalid request.

  File "/home/user/.local/lib/python2.7/site-packages/googleapiclient/http.py", line 840, in execute
    raise HttpError(resp, content, uri=self.uri)
googleapiclient.errors.HttpError: <HttpError 400 when requesting https://appengine.googleapis.com/v1/apps/<project>/services/default?alt=json returned "Invalid request.">

Now when you get the exception and its content the error becomes slightly more verbose.

{
  "error": {
    "code": 400,
    "message": "Invalid request.",
    "errors": [
      {
        "message": "Invalid request.",
        "domain": "global",
        "reason": "badRequest"
      }
    ],
    "status": "INVALID_ARGUMENT"
  }
}

Making the same request manually to the REST API returns a significantly more useful response.

{
  "error": {
    "code": 400,
    "message": "Invalid request.",
    "status": "INVALID_ARGUMENT",
    "details": [
      {
        "@type": "type.googleapis.com/google.rpc.BadRequest",
        "fieldViolations": [
          {
            "field": "service.split.allocations[1]",
            "description": "Allocation must be a value in the range (0, 1]."
          },
          {
            "field": "service.split.allocations",
            "description": "Traffic allocations must sum to 1."
          }
        ]
      }
    ]
  }
}

Metadata

Metadata

Assignees

Labels

🚨This issue needs some love.priority: p1Important issue which blocks shipping the next release. Will be fixed prior to next release.status: acknowledgedtype: 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