Skip to content

SMTPNotifier not working on HITLBranchOperator #57437

@silasdoehler

Description

@silasdoehler

Apache Airflow Provider(s)

standard, smtp

Versions of Apache Airflow Providers

apache-airflow-providers-smtp==2.3.1
apache-airflow-providers-standard==1.9.1

Apache Airflow version

3.1.1

Operating System

devcontainer on macos

Deployment

Other Docker-based deployment

Deployment details

local development: i use astro cli in a devcontainer

What happened

I try to integrate a HITLBranchOperator in my DAG, with an SMTPNotifier for notifications. SMTP is correctly configured (at least i can send emails from my DAGs using send_email_smtp()), the connection is smtp_default.

This is the code snippet (error is the same, no matter if i use SMTPNotifier and send_smtp_notification):

review_export_task = HITLBranchOperator(
        task_id = "review_export",
        subject="Please check the export provided in S3 bucket. See the previous task for detailed errors.",
        options=["send_invoices_export", "abort_export_creation"],
        notifiers=[
            send_smtp_notification(
                from_email="your_mail@example.com",
                to="my_mail@example.com",
                subject="Export needs to be checked",
                html_content="Please check the export provided in S3 bucket"
            )
        ]
    )

When running the task i get this error:

Failed to send notification (sync): Connection.__init__() got an unexpected keyword argument 'ti_id' source=airflow.providers.smtp.notifications.smtp.SmtpNotifier loc=notifier.py:140
[2025-10-28 16:22:18] ERROR - Task failed with exception source=task loc=task_runner.py:994
TypeError: Connection.__init__() got an unexpected keyword argument 'ti_id'
File "/usr/local/lib/python3.12/site-packages/airflow/sdk/execution_time/task_runner.py", line 920 in run

File "/usr/local/lib/python3.12/site-packages/airflow/sdk/execution_time/task_runner.py", line 1307 in _execute_task

File "/usr/local/lib/python3.12/site-packages/airflow/sdk/bases/operator.py", line 416 in wrapper

File "/usr/local/lib/python3.12/site-packages/airflow/providers/standard/operators/hitl.py", line 152 in execute

File "/usr/local/lib/python3.12/site-packages/airflow/sdk/bases/notifier.py", line 138 in __call__

File "/usr/local/lib/python3.12/site-packages/airflow/providers/smtp/notifications/smtp.py", line 152 in notify

File "/usr/local/lib/python3.12/site-packages/airflow/providers/smtp/hooks/smtp.py", line 83 in __enter__

File "/usr/local/lib/python3.12/site-packages/airflow/providers/smtp/hooks/smtp.py", line 121 in get_conn

File "/usr/local/lib/python3.12/site-packages/airflow/sdk/bases/hook.py", line 61 in get_connection

File "/usr/local/lib/python3.12/site-packages/airflow/sdk/definitions/connection.py", line 226 in get

File "/usr/local/lib/python3.12/site-packages/airflow/sdk/execution_time/context.py", line 185 in _get_connection

File "/usr/local/lib/python3.12/site-packages/airflow/sdk/execution_time/context.py", line 116 in _process_connection_result_conn

What you think should happen instead

A mail notification should be sent

How to reproduce

Just add this task to a DAG

Anything else

No response

Are you willing to submit PR?

  • Yes I am willing to submit a PR!

Code of Conduct

Metadata

Metadata

Assignees

Type

No type

Projects

Status

Done

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions