Fix #62414: Remove spurious blank lines in filtered task log download#64235
Conversation
|
Congratulations on your first Pull Request and welcome to the Apache Airflow community! If you have any issues or are unsure about any anything please check our Contributors' Guide (https://github.com/apache/airflow/blob/main/contributing-docs/README.rst)
|
|
Can you please update the PR description with the problem and solution? Ideally with screenshots. Also, tag the relevant github issue if there is one |
Hi, sorry about that I had accidentally commented out the body of the description. Now you have an explanation and some screenshots detailing the problem and fix. |
…wnload When log level or source filters were applied, renderStructuredLog returned empty strings for dropped lines. Joining those with newlines still inserted blank lines, often at the start of the downloaded file.
Reformats getLogString arrow function to stay within line length limit, and fixes object key ordering (content before continuation_token) in test fixtures to match Prettier's alphabetical sorting.
|
Hi @bbovenzi — the Helm, PROD image, and Kubernetes CI jobs are failing on this PR, but my changes are limited to Logs.tsx (a frontend TypeScript file). The failures don't reproduce locally and appear unrelated to the change. Could you re-trigger them, or let me know if there's something I'm missing? |
|
Awesome work, congrats on your first merged pull request! You are invited to check our Issue Tracker for additional contributions. |
…log download (#64235) * Fix #62414: Remove spurious blank lines in filtered task log download When log level or source filters were applied, renderStructuredLog returned empty strings for dropped lines. Joining those with newlines still inserted blank lines, often at the start of the downloaded file. * Fix prek formatting in Logs.tsx and logDownloadContent.test.ts Reformats getLogString arrow function to stay within line length limit, and fixes object key ordering (content before continuation_token) in test fixtures to match Prettier's alphabetical sorting. (cherry picked from commit 32ac564) Co-authored-by: Bernardo Gunzburger Lopes <130933290+bennyc0de@users.noreply.github.com>
Backport successfully created: v3-2-testNote: As of Merging PRs targeted for Airflow 3.X In matter of doubt please ask in #release-management Slack channel.
|
… task log download (apache#64235) * Fix apache#62414: Remove spurious blank lines in filtered task log download When log level or source filters were applied, renderStructuredLog returned empty strings for dropped lines. Joining those with newlines still inserted blank lines, often at the start of the downloaded file. * Fix prek formatting in Logs.tsx and logDownloadContent.test.ts Reformats getLogString arrow function to stay within line length limit, and fixes object key ordering (content before continuation_token) in test fixtures to match Prettier's alphabetical sorting. (cherry picked from commit 32ac564) Co-authored-by: Bernardo Gunzburger Lopes <130933290+bennyc0de@users.noreply.github.com>
…log download (#64235) (#64640) * Fix #62414: Remove spurious blank lines in filtered task log download When log level or source filters were applied, renderStructuredLog returned empty strings for dropped lines. Joining those with newlines still inserted blank lines, often at the start of the downloaded file. * Fix prek formatting in Logs.tsx and logDownloadContent.test.ts Reformats getLogString arrow function to stay within line length limit, and fixes object key ordering (content before continuation_token) in test fixtures to match Prettier's alphabetical sorting. (cherry picked from commit 32ac564) Co-authored-by: Bernardo Gunzburger Lopes <130933290+bennyc0de@users.noreply.github.com>
…log download (#64235) (#64640) * Fix #62414: Remove spurious blank lines in filtered task log download When log level or source filters were applied, renderStructuredLog returned empty strings for dropped lines. Joining those with newlines still inserted blank lines, often at the start of the downloaded file. * Fix prek formatting in Logs.tsx and logDownloadContent.test.ts Reformats getLogString arrow function to stay within line length limit, and fixes object key ordering (content before continuation_token) in test fixtures to match Prettier's alphabetical sorting. (cherry picked from commit 32ac564) Co-authored-by: Bernardo Gunzburger Lopes <130933290+bennyc0de@users.noreply.github.com>
…log download (#64235) (#64640) * Fix #62414: Remove spurious blank lines in filtered task log download When log level or source filters were applied, renderStructuredLog returned empty strings for dropped lines. Joining those with newlines still inserted blank lines, often at the start of the downloaded file. * Fix prek formatting in Logs.tsx and logDownloadContent.test.ts Reformats getLogString arrow function to stay within line length limit, and fixes object key ordering (content before continuation_token) in test fixtures to match Prettier's alphabetical sorting. (cherry picked from commit 32ac564) Co-authored-by: Bernardo Gunzburger Lopes <130933290+bennyc0de@users.noreply.github.com>
…log download (#64235) (#64640) * Fix #62414: Remove spurious blank lines in filtered task log download When log level or source filters were applied, renderStructuredLog returned empty strings for dropped lines. Joining those with newlines still inserted blank lines, often at the start of the downloaded file. * Fix prek formatting in Logs.tsx and logDownloadContent.test.ts Reformats getLogString arrow function to stay within line length limit, and fixes object key ordering (content before continuation_token) in test fixtures to match Prettier's alphabetical sorting. (cherry picked from commit 32ac564) Co-authored-by: Bernardo Gunzburger Lopes <130933290+bennyc0de@users.noreply.github.com>
Problem
When a log level or source filter was active in the Task Instance Logs view, downloading the logs produced an empty or nearly-empty file.
The root cause: renderStructuredLog returns an empty string ("") for each log line that doesn't match the active filter. The getLogString function in Logs.tsx was joining all parsed lines with "\n" — including those empty strings. This meant that if filtered-out lines appeared at the start (or throughout) the log, the downloaded file would be filled with blank lines, or appear empty when all lines were filtered out.
Solution
Filter out empty strings before joining:
This ensures the downloaded file contains only lines that passed the active filter, with no spurious blank lines. A new test file logDownloadContent.test.ts covers the key cases: all lines filtered out, no leading newlines when early lines are excluded, and correct inclusion of lines that match the filter.
Closes: Logs downloaded as empty file when filtering by log level #62414
BEFORE:

AFTER:

Was generative AI tooling used to co-author this PR?
Generated-by: [Claude Sonnet 4.6] following the guidelines