-
Notifications
You must be signed in to change notification settings - Fork 18
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
Show errors in a consistent way #123
Comments
Can you give some examples? What is a not weird format? Not sure I can do anything about the error array response... that's a FastAPI thing. Will check. |
There are currently 3 ways a error is displayed: just in detail, as detail.msg, and detail[X].msg (X is an integer). As a user of blitz_api, I would like to have consistent error messages, either in detail or in detail.msg. Multiple errors are not really necessary IMO, since you could just show the "next" error. Scenario 1When I call {
"detail": [
{
"loc": [
"body",
"password"
],
"msg": "ensure this value has at least 8 characters",
"type": "value_error.any_str.min_length",
"ctx": {
"limit_value": 8
}
}
]
} => So I access When I get an unauthenticated error, e.g. by calling {
"detail": "Not authenticated"
} => So I need to access just Scenario 2When I call {
"detail": "old password format invalid"
} => So I need to access just When I call {
"type": "p2w2"
} I get the details as an array: {
"detail": [
{
"loc": [
"body",
"type"
],
"msg": "value is not a valid enumeration member; permitted: 'p2wkh', 'np2wkh'",
"type": "type_error.enum",
"ctx": {
"enum_values": [
"p2wkh",
"np2wkh"
]
}
}
]
} => So there I need to access |
That there are multiple errors returned is a Fastapi thing. If you call an endpoint with multiple wrong query args then you'll get an error array with an error message for each. We can't change this without forking FastAPI. What we can do is always return an array where the first element is the actual error message. Need to look into this more. |
TIL: https://www.rfc-editor.org/rfc/rfc9457.html This standard describes error handling for apis. Here's more some information: Might be a good idea to implement this standard. |
Currently, the error comes in weird formats, depending on the endpoint.
Do not send an error array. but only one error at a time.
The text was updated successfully, but these errors were encountered: