Visitar URL original
Fix task error email notification sender fallback to connection and provider defaults by olayiwola-gbenga · Pull Request #72745 · apache/airflow · GitHub
Skip to content

Fix task error email notification sender fallback to connection and provider defaults - #72745

Open
olayiwola-gbenga wants to merge 1 commit into
apache:mainfrom
VladaZakharova:fix-error-email-from-email-fallback
Open

olayiwola-gbenga wants to merge 1 commit into
apache:mainfrom
VladaZakharova:fix-error-email-from-email-fallback

Conversation

@olayiwola-gbenga

Copy link
Copy Markdown
Contributor

In Task SDK, _send_error_email_notification passed a hardcoded fallback string 'airflow@airflow' when [email] from_email was not configured. This bypassed provider-specific defaults (such as SendGrid's SENDGRID_MAIL_FROM env var or SES sender verification) when using _LegacyEmailBackendNotifier, and prevented SmtpNotifier from reaching its connection-extra fallback branch.

Default from_email extraction to None so backends and notifiers can resolve their own sender defaults.


Was generative AI tooling used to co-author this PR?
  • Yes (please specify the tool below)

  • Read the Pull Request Guidelines for more information. Note: commit author/co-author name and email in commits become permanently public when merged.
  • For fundamental code changes, an Airflow Improvement Proposal (AIP) is needed.
  • When adding dependency, check compliance with the ASF 3rd Party License Policy.
  • For significant user-facing changes create newsfragment: {pr_number}.significant.rst, in airflow-core/newsfragments. You can add this file in a follow-up commit after the PR is created so you know the PR number.

…rovider defaults

In Task SDK, _send_error_email_notification passed a hardcoded fallback string 'airflow@airflow' when [email] from_email was not configured. This bypassed provider-specific defaults (such as SendGrid's SENDGRID_MAIL_FROM env var or SES sender verification) when using _LegacyEmailBackendNotifier, and prevented SmtpNotifier from reaching its connection-extra fallback branch.

Default from_email extraction to None so backends and notifiers can resolve their own sender defaults.
@olayiwola-gbenga
olayiwola-gbenga force-pushed the fix-error-email-from-email-fallback branch from c95a444 to 4a37d3b Compare September 8, 2026 21:14
@kaxil

kaxil commented Oct 1, 2026

Copy link
Copy Markdown
Member

Closing this. [email] from_email defaults to None, so with this change the default SmtpNotifier path gets from_email=None, and SmtpNotifier raises a ValueError ("You should provide from_email or define it in the connection") unless the SMTP connection sets one. Failure and retry emails that go out from airflow@airflow today would stop being sent in a default setup. The tests only assert that from_email is None.

@kaxil kaxil closed this Oct 1, 2026
@VladaZakharova

Copy link
Copy Markdown
Contributor

I understand your point and the PR can be reworked, but why it was just closed?
@olayiwola-gbenga Can you please provide here the business need for this change?

@olayiwola-gbenga

Copy link
Copy Markdown
Contributor Author

Thanks for the review @kaxil, and thanks @VladaZakharova for following up.

On the business need: in Airflow 2 (airflow.utils.email.send_email), from_email defaulted to None when [email] from_email wasn't set in airflow.cfg. Many users migrating to Airflow 3 use a custom [email] email_backend (like SendGrid or Amazon SES, which now go through _LegacyEmailBackendNotifier) and leave [email] from_email unset so the backend can fall back to its own sender config (such as the SENDGRID_MAIL_FROM env var or connection extras).
Because _send_error_email_notification currently passes "airflow@airflow" as the fallback, _LegacyEmailBackendNotifier passes "airflow@airflow" instead of None to the custom send_email function. That overrides the provider's own default sender and causes task failure/retry emails to be rejected due to an unverified sender address.

@kaxil makes a good point about SmtpNotifier. When I started working on this, there was an open PR for #69262 that updated SmtpNotifier to fall back to "airflow@airflow" instead of raising a ValueError when from_email=None, while leaving _LegacyEmailBackendNotifier with the hardcoded "airflow@airflow". Since that PR was closed without merging, passing from_email=None to SmtpNotifier currently raises a ValueError in a default setup when the SMTP connection doesn't have from_email set.

Since the scope of our ticket is specifically to fix legacy/custom email_backend setups, I can update this PR so fallback=None is only used for _LegacyEmailBackendNotifier while keeping fallback="airflow@airflow" for SmtpNotifier, and update the tests accordingly.

@kaxil could we reopen this PR so I can push that change?

@kaxil

kaxil commented Oct 8, 2026

Copy link
Copy Markdown
Member

Happy to reopen it @olayiwola-gbenga . But do ensure you follow PR guidelines, and show enough evidence of testing with before/after.

The current influx of PRs is not maintainable from the PR review standpoint, so any PRs that don't provide enough details, or are clearly AI slop -- will be closed without any further explanation.

@kaxil kaxil reopened this Oct 8, 2026

This branch has not been deployed

No deployments
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.

3 participants