google-api-python-client
google-api-python-client copied to clipboard
details missing in googleapiclient.errors.HttpError
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."
}
]
}
]
}
}
Seems like it might just be dropping the "details" section on the floor. I'm happy to review a patch to fix this, or we'll get to it when we can.
@jonparrott Thanks in advance for a review.