Improve Post-Task logs to show exception in failure#66735
Open
jscheffl wants to merge 1 commit into
Open
Conversation
vatsrahul1001
approved these changes
May 12, 2026
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.
Following-up on the PR by @ashb in #66037 I realized the same shotcoming with the change as some (my local) users complained about in Airflow 2.x as well: If the task fails the Exception details are swallowed/hidden in the post execution block. Experienced users complianed they always need to click to un-fold to see details and in-experienced users did not see any error and wondered why task was failing.
Before (so after @ashb added folding for Pre/Post task (THANKS!!!):

Successful task:
Failed task (mis-leading as last log line has no error and is INFO!):

Need to un-fold to see the error actually:

With this PR the exception in case of task failure is moved above the Post-Execution log group:

(So no un-folding of group needed, only "boring" logs below exception):

I admit the code is not as elegant as before with a single group but now scattered across multiple different exception catching blocks. Ideas for more elegant placing welcome. But UX should be good first (over code beautiness)
Note: Just adjusted primary code, will fix pytests tomorrow but leave PR here for catching comments on change.
Was generative AI tooling used to co-author this PR?
{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.