-
Notifications
You must be signed in to change notification settings - Fork 624
Open
Description
BadRequest may only have field violations and no header violations. Why? Shouldn't we add support for header violations as well?
So the following error:
$ curl -H 'Authorization: Bearer <REDACTED>' https://chat.googleapis.com/v1/spaces
{
"error": {
"code": 401,
"message": "Request had invalid authentication credentials. Expected OAuth 2 access token, login cookie or other valid authentication credential. See https://developers.google.com/identity/sign-in/web/devconsole-project.",
"status": "UNAUTHENTICATED"
}
}
could look like this:
{
"error": {
"code": 401,
"message": "Request had invalid authentication credentials. Expected OAuth 2 access token, login cookie or other valid authentication credential. See https://developers.google.com/identity/sign-in/web/devconsole-project.",
"status": "UNAUTHENTICATED",
"details": [
{
"@type": "type.googleapis.com/google.rpc.BadRequest",
"headerViolations": [
{
"header": "Authorization",
"description": "Missing or invalid OAuth 2 access token in Authorization header."
},
{
"header": "Cookie",
"description": "Missing or invalid login cookie."
}
]
}
]
}
}
here's another usage example:
{
"error": {
"code": 400,
"message": "Failed to parse 'Content-Type' header as UTF-8.",
"status": "INVALID_ARGUMENT",
"details": [
{
"@type": "type.googleapis.com/google.rpc.BadRequest",
"headerViolations": [
{
"header": "Content-Type",
"description": "The value of the 'Content-Type' header could not be decoded as UTF-8. Please ensure it is properly encoded."
}
]
}
]
}
}
Drawbacks:
- There's an overhead of N bytes for storing an array of header violations for each response, in Rust it's 24 bytes even when the array is empty.
Metadata
Metadata
Assignees
Labels
No labels