Skip to content

Amazon Airflow Provider | Broken AWS SES as backend for Email #21671

@dbarrundiag

Description

@dbarrundiag

Apache Airflow Provider(s)

amazon

Versions of Apache Airflow Providers

apache-airflow==2.2.2
apache-airflow-providers-amazon==2.4.0

Apache Airflow version

2.2.2

Operating System

Amazon Linux 2

Deployment

MWAA

Deployment details

No response

What happened

As part of this PR #18042 the signature of the function airflow.providers.amazon.aws.utils.emailer.send_email is no longer compatible with how airflow.utils.email.send_email invokes the function. Essentially the functionally of using SES as Email Backend is broken.

What you expected to happen

This behavior is erroneous because the signature of airflow.providers.amazon.aws.utils.emailer.send_email should be compatible with how we call the backend function in airflow.utils.email.send_email:

    return backend(
        to_comma_separated,
        subject,
        html_content,
        files=files,
        dryrun=dryrun,
        cc=cc,
        bcc=bcc,
        mime_subtype=mime_subtype,
        mime_charset=mime_charset,
        conn_id=backend_conn_id,
        **kwargs,
    )

How to reproduce

Use AWS SES as Email Backend

[email]
email_backend = airflow.providers.amazon.aws.utils.emailer.send_email
email_conn_id = aws_default

Try sending an Email

from airflow.utils.email import send_email

def email_callback(**kwargs):
    send_email(to=['test@hello.io'], subject='test', html_content='content')

email_task = PythonOperator(
    task_id='email_task',
    python_callable=email_callback,
)

The bug shows up

  File "/usr/local/airflow/dags/environment_check.py", line 46, in email_callback
    send_email(to=['test@hello.io'], subject='test', html_content='content')
  File "/usr/local/lib/python3.7/site-packages/airflow/utils/email.py", line 66, in send_email
    **kwargs,
TypeError: send_email() missing 1 required positional argument: 'html_content'

Anything else

Every time.

Are you willing to submit PR?

  • Yes I am willing to submit a PR!

Code of Conduct

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions