This is an automated email from the ASF dual-hosted git repository.
jedcunningham pushed a commit to branch v3-1-test
in repository https://gitbox.apache.org/repos/asf/airflow.git
The following commit(s) were added to refs/heads/v3-1-test by this push:
new 1b33eb631f7 [v3-1-test] Emit log stream stopped warning as ndjson
(#56474) (#56480)
1b33eb631f7 is described below
commit 1b33eb631f7ea46c96807b0b060d86f114e048f4
Author: github-actions[bot]
<41898282+github-actions[bot]@users.noreply.github.com>
AuthorDate: Wed Oct 8 11:40:36 2025 -0600
[v3-1-test] Emit log stream stopped warning as ndjson (#56474) (#56480)
Changes the format of the log stream stopped warning emitted by the
TaskLogReader to ndjson when it encounters no end of log marker in a stream.
Mixing ndjson and non-ndjson means the UI will not show any logs at all.
(cherry picked from commit 87826505f25278928e1a42e12dd2a04d7eb584b3)
Co-authored-by: Ian Buss <[email protected]>
---
airflow-core/src/airflow/utils/log/log_reader.py | 3 ++-
airflow-core/tests/unit/utils/log/test_log_reader.py | 2 +-
2 files changed, 3 insertions(+), 2 deletions(-)
diff --git a/airflow-core/src/airflow/utils/log/log_reader.py
b/airflow-core/src/airflow/utils/log/log_reader.py
index 6b596b7d621..c238c7d4d4d 100644
--- a/airflow-core/src/airflow/utils/log/log_reader.py
+++ b/airflow-core/src/airflow/utils/log/log_reader.py
@@ -147,7 +147,8 @@ class TaskLogReader:
empty_iterations += 1
if empty_iterations >=
self.STREAM_LOOP_STOP_AFTER_EMPTY_ITERATIONS:
# we have not received any logs for a while, so we
stop the stream
- yield "(Log stream stopped - End of log marker not
found; logs may be incomplete.)\n"
+ # this is emitted as json to avoid breaking the ndjson
stream format
+ yield '{"event": "Log stream stopped - End of log
marker not found; logs may be incomplete."}\n'
return
else:
#
https://mypy.readthedocs.io/en/stable/typed_dict.html#supported-operations
diff --git a/airflow-core/tests/unit/utils/log/test_log_reader.py
b/airflow-core/tests/unit/utils/log/test_log_reader.py
index 1818e1b5d6d..c32635d59df 100644
--- a/airflow-core/tests/unit/utils/log/test_log_reader.py
+++ b/airflow-core/tests/unit/utils/log/test_log_reader.py
@@ -268,7 +268,7 @@ class TestLogView:
log_stream = task_log_reader.read_log_stream(ti=self.ti, try_number=1,
metadata={})
assert list(log_stream) == [
'{"timestamp":null,"event":"hello"}\n',
- "(Log stream stopped - End of log marker not found; logs may be
incomplete.)\n",
+ '{"event": "Log stream stopped - End of log marker not found; logs
may be incomplete."}\n',
]
assert mock_read.call_count == 11