-
Notifications
You must be signed in to change notification settings - Fork 375
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add ErrorInfo support to GCS #7644
Comments
From https://cloud.google.com/apis/design/errors#http_mapping, an example response with "error info" data is: {
"error": {
"code": 400,
"message": "API key not valid. Please pass a valid API key.",
"status": "INVALID_ARGUMENT",
"details": [
{
"@type": "type.googleapis.com/google.rpc.ErrorInfo",
"reason": "API_KEY_INVALID",
"domain": "googleapis.com",
"metadata": {
"service": "translate.googleapis.com"
}
}
]
}
} |
Question: Within |
I do not think we can guarantee that it is always JSON. Some error messages arrive from the load balancer, where they are not necessarily in JSON format. But when the error message is from the JSON API, then they are in the format outlined above. We can try to parse them as JSON, and if that fails we just stick the full message in the message string (as we do today). If the parsing succeeds, then we can extract the |
Fixes: googleapis#7644 Please review this nlohmann code closely, because I've never used it and I may be doing things the least optimal way.
One problem currently is that GCS (or maybe it's the emulator) is returning some valid JSON that I'm not expecting. According to https://cloud.google.com/apis/design/errors#http_mapping, my code expects error JSON of the form: {
"error": {
"code": ...,
"message": "..."
...
"details": [
...
]
}
} But I'm sometimes seeing JSON of the form {
"code": ...,
"message": ...
} That is, I see JSON data that looks like the contents of the "error" object. So I'm not sure which of these formats I should actually expect. |
Ugh... That might be the emulator, specifically the code around here: https://github.com/googleapis/storage-testbench/blob/main/testbench/error.py#L37 |
Fixes: googleapis#7644 Please review this nlohmann code closely, because I've never used it and I may be doing things the least optimal way.
Fixes: #7644 Follows https://cloud.google.com/apis/design/errors#http_mapping and parses the "error info" json object from responses when it's available, and uses it to set the fields of the returned `g::c::Status`.
This is a follow on issue related to #7429. In that issue, we added ErrorInfo support to
g::c::Status
, per https://google.aip.dev/193. That's now done for gRPC based services.GCS is not gRPC, and so it needs the ability to fill in the ErrorInfo class that's (optionally) passed to
g::c::Status
. Per @coryan 's comment in #7640The text was updated successfully, but these errors were encountered: