RFC 9457 error responses #20736
Unanswered
chrisguidry
asked this question in
Ideas
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
I just came across RFC 9457: Problem Details for HTTP APIs which describes a standardized way to report errors from REST APIs. The RFC describes a mime type "application/problem+json" and a standard set of JSON fields, like
type,detail, andinstance. While this RFC is still just a Proposed Standard, it would be more widely adopted than our ad-hoc error handling approach.When I audited Prefect and Prefect Cloud, I found that we were kinda-sorta abiding by this convention, just mostly inherited from FastAPI. Worse, both systems differ in their error reporting approaches depending on the endpoints, what type of exceptions are raised, and which handler is actually catching errors and formatting responses. The two systems also differ from one another in some instances.
I propose that we unify these, while still preserving all of the extant error messaging fields for compatibility. Preserving compatibility should be straightforward, at the expense of some duplicated keys; the RFC is fine with additional fields (https://www.rfc-editor.org/rfc/rfc9457.html#section-3.1).
Migration approach:
Content-Type: application/problem+jsonif it was explicitly requested via anAccept: application/json, application/problem+jsonheader. Otherwise, keep the currentapplication/jsonfor all responses.Accept: application/json, application/problem+jsonI see no need to ever drop the older fields from our responses, but perhaps with a future major version break we could do that. We could also conditionally decide to return the stricter subset to clients that are asking for
application/problem+jsonin theirAcceptheaders.Beta Was this translation helpful? Give feedback.
All reactions