Skip to content

Fix crash when tailing logs of a running task instance#69503

Merged
jason810496 merged 1 commit into
apache:mainfrom
jason810496:fix/logging/is-logs-stream-like-islice
Jul 7, 2026
Merged

Fix crash when tailing logs of a running task instance#69503
jason810496 merged 1 commit into
apache:mainfrom
jason810496:fix/logging/is-logs-stream-like-islice

Conversation

@jason810496

@jason810496 jason810496 commented Jul 7, 2026

Copy link
Copy Markdown
Member

Why

FileTaskHandler.read() raises TypeError: Invalid log stream type... Got islice instead whenever a client polls/tails the logs of a running task (any read after the first, i.e. metadata["log_pos"] is set) — a regression from #63531 in released Airflow 3.2.2.

  • Fix duplicate log reads when resuming from log_pos #63531 fixed _read() to correctly reassign out_stream = islice(out_stream, metadata["log_pos"], None), but that changed out_stream's runtime type from GeneratorType to itertools.islice.
  • The public read() wrapper dispatches on _is_logs_stream_like(), which only recognized chain/GeneratorType — not islice — so it fell through every branch and raised TypeError.

What

  • Add islice to _is_logs_stream_like's isinstance tuple.
  • But not using Iterator with isinstance as the purpose of _is_logs_stream_like is distinguishing whether the given "iterator" log source is coming "from stream interface" or not, Iterator is too board.

Was generative AI tooling used to co-author this PR?

FileTaskHandler._read() returns an itertools.islice stream when
resuming a log read via metadata["log_pos"] (introduced in apache#63531),
but _is_logs_stream_like() only recognized chain and generator
objects, so the public read() wrapper raised
TypeError: Invalid log stream type... Got islice instead
whenever a client polled or tailed a running task's logs.
@jason810496 jason810496 self-assigned this Jul 7, 2026
@jason810496 jason810496 added the area:API Airflow's REST/HTTP API label Jul 7, 2026
@jason810496 jason810496 requested a review from Lee-W July 7, 2026 04:15
@jason810496 jason810496 merged commit 87089a5 into apache:main Jul 7, 2026
148 checks passed
@jason810496

Copy link
Copy Markdown
Member Author

I forgot to add the v3-3-test label while merging, manully backport in #69521.

@jason810496 jason810496 added this to the Airflow 3.3.1 milestone Jul 7, 2026
jason810496 added a commit to jason810496/airflow that referenced this pull request Jul 7, 2026
…pache#69503)

FileTaskHandler._read() returns an itertools.islice stream when
resuming a log read via metadata["log_pos"] (introduced in apache#63531),
but _is_logs_stream_like() only recognized chain and generator
objects, so the public read() wrapper raised
TypeError: Invalid log stream type... Got islice instead
whenever a client polled or tailed a running task's logs.
(cherry picked from commit 87089a5)

Co-authored-by: Jason(Zhe-You) Liu <68415893+jason810496@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:API Airflow's REST/HTTP API area:logging

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants