This is an automated email from the ASF dual-hosted git repository.

jedcunningham pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/airflow.git


The following commit(s) were added to refs/heads/main by this push:
     new 87826505f25 Emit log stream stopped warning as ndjson (#56474)
87826505f25 is described below

commit 87826505f25278928e1a42e12dd2a04d7eb584b3
Author: Ian Buss <[email protected]>
AuthorDate: Wed Oct 8 17:25:23 2025 +0100

    Emit log stream stopped warning as ndjson (#56474)
    
    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.
---
 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
 

Reply via email to