Skip to content

Fix: Consistent no-log handling for tasks with try_number=0 in API and UI (#54749) - #55035

Merged
uranusjr merged 2 commits into
apache:mainfrom
Prasanth345:fix-54749-task-log-no-attempt-messages
Sep 2, 2025
Merged

uranusjr merged 2 commits into
apache:mainfrom
Prasanth345:fix-54749-task-log-no-attempt-messages

Conversation

@Prasanth345

@Prasanth345 Prasanth345 commented Aug 28, 2025 •

Copy link
Copy Markdown
Contributor

Summary

This PR ensures consistent handling of no-log cases for tasks when try_number=0.
Instead of returning empty or confusing responses, the system now provides clear, structured messages across both UI and API log views.

Implementation Details

  • Added a check for try_number=0 before calling read_log_chunks.
  • Introduced fallback structured log responses for specific states:
    • SKIPPED → "Task was skipped — no logs available."
    • UPSTREAM_FAILED → "Task did not run because upstream task(s) failed."
    • Others → "No logs available for this task."
  • Reused structured log format to match API/UI expectations (timestamp, event, level, sources).
  • Ensured this logic is applied consistently in log streaming and API responses.

Testing

  • Verified DAG runs where tasks were SKIPPED and UPSTREAM_FAILED.
  • Confirmed that API responses now return structured fallback logs instead of empty logs.
  • Checked that UI log viewer shows the same messages, ensuring consistency.

Why

Previously, tasks with try_number=0 produced inconsistent log responses:

  • API often returned empty logs.
  • UI displayed misleading or missing messages.

This change standardizes the behavior, improving observability and debugging for users.

Related Issue

Closes #54749

Below find the screenshots

Screenshot from 2025-09-01 01-00-59 Screenshot from 2025-09-01 01-01-09

@boring-cyborg boring-cyborg Bot added area:API Airflow's REST/HTTP API area:logging labels Aug 28, 2025
@Prasanth345
Prasanth345 force-pushed the fix-54749-task-log-no-attempt-messages branch 2 times, most recently from 4242fb5 to 9b197df Compare August 28, 2025 22:56

@jason810496 jason810496 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the PR!

@Prasanth345
Prasanth345 force-pushed the fix-54749-task-log-no-attempt-messages branch from 9b197df to c049a0d Compare August 31, 2025 19:27
@Prasanth345

Copy link
Copy Markdown
Contributor Author

Hi @jason810496, thanks for your suggestions. I’ve updated the code as per your feedback — could please you review it once?

@eladkal eladkal added this to the Airflow 3.0.7 milestone Sep 1, 2025

@jason810496 jason810496 left a comment •

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice! Thanks for the PR!
It would be nice to add the test in airflow-core/tests/unit/utils/log/test_log_reader.py, then this PR is good to go.

Having pytest parameterize with different TI try_number to check the output result would be great.

@Prasanth345

Copy link
Copy Markdown
Contributor Author

@jason810496, I’ve added test cases — could please you review it once?

@uranusjr
uranusjr requested a review from jason810496 September 2, 2025 04:07

@jason810496 jason810496 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for adding the test.

@uranusjr
uranusjr merged commit 22677de into apache:main Sep 2, 2025
github-actions Bot pushed a commit that referenced this pull request Sep 2, 2025
…=0 in API and UI (#54749) (#55035)

(cherry picked from commit 22677de)

Co-authored-by: Kumbha Lakshmi Narayana <[email protected]>
@github-actions

github-actions Bot commented Sep 2, 2025

Copy link
Copy Markdown
Contributor

Backport successfully created: v3-0-test

Status Branch Result
✅ v3-0-test PR Link

eladkal pushed a commit that referenced this pull request Sep 3, 2025
…=0 in API and UI (#54749) (#55035) (#55162)

(cherry picked from commit 22677de)

Co-authored-by: Kumbha Lakshmi Narayana <[email protected]>
@kaxil kaxil removed this from the Airflow 3.0.7 milestone Sep 13, 2025
@kaxil kaxil added this to the Airflow 3.1.0 milestone Sep 13, 2025
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.

Skipped task logs issues an error fetching logs

5 participants