Standardize Execution API error responses to RFC 9457#67286
Open
23tae wants to merge 3 commits into
Open
Conversation
Member
|
Status is moot in the response body -- that's already included in the HTTP response and shouldn't be duplicated. |
8f8d874 to
4fd579c
Compare
Contributor
Author
@ashb Thanks for the feedback! You're right—since the status code is already in the HTTP response, having it in the body is redundant. I've removed the Before: {
"detail": {
"type": "about:blank",
"title": "Internal Server Error",
"status": 500,
"detail": "Database error occurred"
}
}After: {
"detail": {
"type": "about:blank",
"title": "Internal Server Error",
"detail": "Database error occurred"
}
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR standardizes the Airflow Execution API error responses to follow the RFC 9457 (Problem Details for HTTP APIs) specification.
Description
Exceptions in the Execution API are caught at the FastAPI route boundary in
task_instances.pyand re-raised as standardHTTPExceptions. Airflow's core API framework then automatically formats these into RFC 9457 compliant JSON.Error Response Examples
This PR demonstrates two key improvements in error handling:
Case 1: Upgrading plain string messages to structured objects
Before:
{ "detail": "Database error occurred" }After:
{ "detail": { "type": "about:blank", "title": "Internal Server Error", "detail": "Database error occurred" } }Case 2: Standardizing dictionaries while retaining custom context
Before:
{ "detail": { "reason": "running_elsewhere", "message": "TI is already running elsewhere", "current_hostname": "worker-1", "current_pid": 12345 } }After:
{ "detail": { "type": "about:blank", "title": "Conflict", "detail": "TI is already running elsewhere", "reason": "running_elsewhere", "current_hostname": "worker-1", "current_pid": 12345 } }Verification Results
I have verified the changes using
prekandbreeze.closes: #62107
Was generative AI tooling used to co-author this PR?
Generated-by: Antigravity following the guidelines
{pr_number}.significant.rst, in airflow-core/newsfragments. You can add this file in a follow-up commit after the PR is created so you know the PR number.