Skip to content

Improve default task failure email template for readability#61729

Closed
Fury0508 wants to merge 6 commits into
apache:mainfrom
Fury0508:improve-email-template-61667
Closed

Improve default task failure email template for readability#61729
Fury0508 wants to merge 6 commits into
apache:mainfrom
Fury0508:improve-email-template-61667

Conversation

@Fury0508

@Fury0508 Fury0508 commented Feb 10, 2026

Copy link
Copy Markdown
Contributor

Improve default task failure email template for readability

Description

Replaces the default task failure email template to improve operator experience and mobile readability.

Problem:
Current default shows raw Python object dumps (UUIDs, repr(), internal fields), making it hard to quickly identify which DAG/task failed and find logs.

Solution:

  • Professional HTML template with dark theme matching Airflow UI
  • Structured display: DAG, task, run ID, attempt, host, tags
  • Clear exception formatting in highlighted box
  • Action buttons for "View Log" and "Mark Success"
  • Plain text fallback for non-HTML email clients
  • Airflow 3.x compatibility (conditional rendering for optional attributes)
  • Fully backward compatible (custom templates still work)

Screenshots

ss

Testing

  • ✅ Templates render correctly with mock task data
  • ✅ Handles missing URLs gracefully (Airflow 3.x compatibility)
  • ✅ Email delivery tested via MailHog SMTP server
  • ✅ Backward compatibility verified

Files Changed

+ airflow-core/src/airflow/templates/email/task_failure_subject.txt
+ airflow-core/src/airflow/templates/email/task_failure_body.html
+ airflow-core/src/airflow/templates/email/task_failure_body.txt
M task-sdk/src/airflow/sdk/execution_time/task_runner.py

closes: #61667


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

Claude AI was used to:

  • Design the HTML email template
  • Locate correct files in Airflow 3.x codebase (task_runner.py)
  • Create test scripts for validation
  • Set up MailHog for email testing

The contributor reviewed all code, tested the implementation, and validated against issue requirements.


Comment thread task-sdk/src/airflow/sdk/execution_time/task_runner.py
Comment thread task-sdk/src/airflow/sdk/execution_time/task_runner.py Outdated
@Fury0508

Fury0508 commented Mar 2, 2026

Copy link
Copy Markdown
Contributor Author

Hi everyone,

Apologies for the lack of activity on this PR. Due to a family emergency, I was unable to dedicate time to updating the code over the past few days.

I am now back and will be actively working on this. I plan to address all the pending review comments and push the necessary changes within the next 2 days.

Thank you for your patience and understanding. 🙏

@eladkal

eladkal commented Mar 29, 2026

Copy link
Copy Markdown
Contributor

@Fury0508 lets us know when the PR is ready for 2nd review.

Comment thread task-sdk/src/airflow/sdk/templates/email/task_failure_body.html Outdated
- Replace plain text email with professional HTML template
- Add dark-themed design matching Airflow UI
- Include structured task details (run, attempt, host, tags)
- Add Airflow 3.x compatibility (conditional rendering for URLs)
- Provide plain text fallback for email clients without HTML support
- Maintain backward compatibility (custom templates still work)

Fixes apache#61667
Replace the current default task failure email template with a modern,
operator-friendly version that addresses readability issues.

- Add professional HTML template with dark theme matching Airflow UI
- Include structured task details (DAG, task, run ID, attempt, host, tags)
- Add clear exception formatting in highlighted box
- Include action buttons for View Log and Mark Success
- Provide plain text fallback for non-HTML email clients
- Add Airflow 3.x compatibility with conditional rendering
- Maintain backward compatibility (custom templates still work)
- Add Apache License headers to all template files

closes: apache#61667
Replace the current default task failure email template with a modern,
operator-friendly version that addresses readability issues.

- Add professional HTML template with dark theme matching Airflow UI
- Include structured task details (DAG, task, run ID, attempt, host, tags)
- Add clear exception formatting in highlighted box
- Include action buttons for View Log and Mark Success
- Provide plain text fallback for non-HTML email clients
- Add Airflow 3.x compatibility with conditional rendering
- Maintain backward compatibility (custom templates still work)
- Add Apache License headers to all template files

closes: apache#61667
…string

- Move email templates from airflow-core to task-sdk to avoid
  cross-package dependency between airflow-core and task-sdk
- Update template path to use Path(__file__).parent.parent
- Restore accidentally removed module docstring
…string

- Move email templates from airflow-core to task-sdk to avoid
  cross-package dependency between airflow-core and task-sdk
- Update template path to use Path(__file__).parent.parent
- Restore accidentally removed module docstring
- Improve subject line to show DAG.task and run context clearly
- Add new email_content.jinja2 HTML template with dark theme matching Airflow UI
- Display task details (DAG, task, run ID, attempt, state, host) in structured grid
- Conditional action buttons for View Log and Mark Success (Airflow 3.x safe)
- Handle both task failure (ti context) and SLA missed context
- Remove task-sdk templates and revert task_runner.py (email belongs in smtp provider)

Closes apache#61667
@Fury0508 Fury0508 force-pushed the improve-email-template-61667 branch from 839d94a to ae6eeeb Compare March 31, 2026 20:51
@Fury0508 Fury0508 requested a review from hussein-awala as a code owner March 31, 2026 20:51
@Fury0508 Fury0508 requested review from amoghrajesh and eladkal March 31, 2026 22:03
@potiuk potiuk added the ready for maintainer review Set after triaging when all criteria pass. label Apr 2, 2026

@jscheffl jscheffl left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Looks good for me, @amoghrajesh how about you?

@potiuk potiuk marked this pull request as draft May 6, 2026 10:59
@potiuk

potiuk commented May 6, 2026

Copy link
Copy Markdown
Member

@Fury0508 This PR has had no activity for 5 weeks. Converting to draft to signal that maintainer review is paused until you resume work.

When you're ready to continue, please rebase onto the current main branch, address any newly-appearing CI failures, and mark the PR as "Ready for review" again. There is no rush.


Note: This comment was drafted by an AI-assisted triage tool and may contain mistakes. Once you have addressed the points above, an Apache Airflow maintainer — a real person — will take the next look at your PR. We use this two-stage triage process so that our maintainers' limited time is spent where it matters most: the conversation with you.

@potiuk potiuk removed the ready for maintainer review Set after triaging when all criteria pass. label May 18, 2026
@potiuk

potiuk commented Jun 1, 2026

Copy link
Copy Markdown
Member

@Fury0508 This draft PR has had no activity for 2 weeks. Closing to keep the queue clean.

You are welcome to reopen and continue when you're ready. If you'd like to pick it back up, please rebase onto the current main branch first.


Note: This comment was drafted by an AI-assisted triage tool and may contain mistakes. Once you have addressed the points above, an Apache Airflow maintainer — a real person — will take the next look at your PR. We use this two-stage triage process so that our maintainers' limited time is spent where it matters most: the conversation with you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Improve default task failure email template for readability and operational clarity

5 participants