You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Exceptions in task logs no longer contain source code #55910
Airflow 3 no longer captures all the lines from an Exception. It seems like it displays part of the traceback but not the actual lines of code. This makes debugging difficult.
Hmmm, those two screenshots that you included have different exceptions. The first (Airflow 2.X) looks like it is failing to fetch a Git repository. I was NOT able to reproduce this exception, and have not seen anything similar before. I'll leave this open in case someone else is able to reproduce.
is there any update on it ? I am also experiencing same problem. No verbose content about Exception it shows -> ERROR - Task failed with exception. Version 3.1.8
This reproduces, and the cause looks structural rather than a formatting slip — it only affects deployments using JSON log output, which may be why it hasn't reproduced for everyone in this thread.
Where the source lines go missing
shared/logging/src/airflow_shared/logging/structlog.py builds the JSON branch's exception renderer from structlog's ExceptionDictTransformer:
That transformer emits one dict per frame containing filename, lineno and name — and nothing else. There is no field carrying the source text of the line, so the rendered traceback can only ever show the frame headers, never the indented code line beneath them. Checked against structlog 26.1.0:
use_rich makes no difference here; both paths produce the same three keys.
Why it's specific to JSON output
The non-JSON branch of the same function uses structlog.dev.plain_traceback (or RichTracebackFormatter when DEV is set), and those go through traceback.print_exception, which pulls the source line via linecache. Both retain the code line. So the same failing task shows full tracebacks in text output and header-only tracebacks in JSON output.
That matches the Airflow 2 → 3 change: the standard-library formatting that carried the source line is no longer on the path for structured logs.
Question before anyone writes a patch
Restoring the code line would mean carrying it per frame — for example a transformer that adds linecache.getline(filename, lineno) alongside the existing keys, with the UI rendering it under each frame. That does make every logged traceback bigger, and show_locals=False / use_rich=False suggest the current settings were chosen deliberately to keep structured logs compact.
Is restoring parity with the text output something the project wants, and if so is a per-frame source field the right shape — or would you rather this stayed as is and the docs noted the difference? Happy to put up a PR once there's a direction.
Drafted-by: Claude Code (Opus 5); reviewed by @Arose26 before posting
I've opened #75100 for this, following the approach suggested above: each frame in the JSON traceback gets a line field (read via linecache, as the stdlib traceback module does), and the UI shows it under the frame.
On the open questions:
Scope: this isn't limited to deployments that opt into JSON output. The task process always logs JSON to the supervisor, so every task log viewed in the UI is affected.
Size: it adds one stripped source line per frame, only when an exception is logged. Frames without available source are unchanged, and plain log lines are unaffected (the PR has a small benchmark).
Happy to change the shape if maintainers would prefer something else.
Activity
jroachgolf84 commentedon Sep 21, 2025
Hmmm, those two screenshots that you included have different exceptions. The first (Airflow 2.X) looks like it is failing to fetch a Git repository. I was NOT able to reproduce this exception, and have not seen anything similar before. I'll leave this open in case someone else is able to reproduce.
NilsJPWerner commentedon Sep 22, 2025
I will try to create another replication.
NilsJPWerner commentedon Sep 22, 2025
Updated with better comparison.
It seems like airflow 3 does not show the indented part of the exception frame that shows the contents of the line of code.
[-]Exceptions are not logged properly[/-][+]Exceptions in task logs no longer contain source code[/+]Venture200 commentedon Jul 15, 2026
is there any update on it ? I am also experiencing same problem. No verbose content about Exception it shows -> ERROR - Task failed with exception. Version 3.1.8
koleharv commentedon Aug 17, 2026
This reproduces, and the cause looks structural rather than a formatting slip — it only affects deployments using JSON log output, which may be why it hasn't reproduced for everyone in this thread.
Where the source lines go missing
shared/logging/src/airflow_shared/logging/structlog.pybuilds the JSON branch's exception renderer from structlog'sExceptionDictTransformer:That transformer emits one dict per frame containing
filename,linenoandname— and nothing else. There is no field carrying the source text of the line, so the rendered traceback can only ever show the frame headers, never the indented code line beneath them. Checked against structlog 26.1.0:use_richmakes no difference here; both paths produce the same three keys.Why it's specific to JSON output
The non-JSON branch of the same function uses
structlog.dev.plain_traceback(orRichTracebackFormatterwhenDEVis set), and those go throughtraceback.print_exception, which pulls the source line vialinecache. Both retain the code line. So the same failing task shows full tracebacks in text output and header-only tracebacks in JSON output.That matches the Airflow 2 → 3 change: the standard-library formatting that carried the source line is no longer on the path for structured logs.
Question before anyone writes a patch
Restoring the code line would mean carrying it per frame — for example a transformer that adds
linecache.getline(filename, lineno)alongside the existing keys, with the UI rendering it under each frame. That does make every logged traceback bigger, andshow_locals=False/use_rich=Falsesuggest the current settings were chosen deliberately to keep structured logs compact.Is restoring parity with the text output something the project wants, and if so is a per-frame source field the right shape — or would you rather this stayed as is and the docs noted the difference? Happy to put up a PR once there's a direction.
Drafted-by: Claude Code (Opus 5); reviewed by @Arose26 before posting
souradeep07 commentedon Oct 19, 2026
I've opened #75100 for this, following the approach suggested above: each frame in the JSON traceback gets a
linefield (read vialinecache, as the stdlibtracebackmodule does), and the UI shows it under the frame.On the open questions:
Happy to change the shape if maintainers would prefer something else.
Show source code lines in task log tracebacks
Show source code lines in task log tracebacks (apache#75100)
[v3-4-test] Show source code lines in task log tracebacks (#75100) (#…