You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by "silasdoehler (via GitHub)" <gi...@apache.org> on 2025/10/28 15:36:43 UTC
[I] SMTPNotifier not working on HITLBranchOperator [airflow]
silasdoehler opened a new issue, #57437:
URL: https://github.com/apache/airflow/issues/57437
### 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
- [x] I agree to follow this project's [Code of Conduct](https://github.com/apache/airflow/blob/main/CODE_OF_CONDUCT.md)
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [I] SMTPNotifier not working on HITLBranchOperator [airflow]
Posted by "amoghrajesh (via GitHub)" <gi...@apache.org>.
amoghrajesh commented on issue #57437:
URL: https://github.com/apache/airflow/issues/57437#issuecomment-3462178642
Figured it out, pushing a fix: https://github.com/apache/airflow/issues/57437
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [I] SMTPNotifier not working on HITLBranchOperator [airflow]
Posted by "boring-cyborg[bot] (via GitHub)" <gi...@apache.org>.
boring-cyborg[bot] commented on issue #57437:
URL: https://github.com/apache/airflow/issues/57437#issuecomment-3457126100
Thanks for opening your first issue here! Be sure to follow the issue template! If you are willing to raise PR to address this issue please do so, no need to wait for approval.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [I] SMTPNotifier not working on HITLBranchOperator [airflow]
Posted by "amoghrajesh (via GitHub)" <gi...@apache.org>.
amoghrajesh closed issue #57437: SMTPNotifier not working on HITLBranchOperator
URL: https://github.com/apache/airflow/issues/57437
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [I] SMTPNotifier not working on HITLBranchOperator [airflow]
Posted by "amoghrajesh (via GitHub)" <gi...@apache.org>.
amoghrajesh commented on issue #57437:
URL: https://github.com/apache/airflow/issues/57437#issuecomment-3459994503
Added it to 3.1.2 milestone
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [I] SMTPNotifier not working on HITLBranchOperator [airflow]
Posted by "tirkarthi (via GitHub)" <gi...@apache.org>.
tirkarthi commented on issue #57437:
URL: https://github.com/apache/airflow/issues/57437#issuecomment-3457347541
cc: @Lee-W
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [I] SMTPNotifier not working on HITLBranchOperator [airflow]
Posted by "Lee-W (via GitHub)" <gi...@apache.org>.
Lee-W commented on issue #57437:
URL: https://github.com/apache/airflow/issues/57437#issuecomment-3461289291
In the latest main, the issue now locates in https://github.com/apache/airflow/blob/278a7560796faa73ab81457f232bd178392ed994/task-sdk/src/airflow/sdk/execution_time/context.py#L158-L170
I'm now using a the HITL example dag but change the notify function as
```python
def notify(self, context: Context) -> None:
from airflow.sdk.definitions.connection import Connection
conn = Connection.get("smtp_default")
url = HITLOperator.generate_link_to_ui_from_context(
context=context,
base_url="http://localhost:28080",
)
self.log.info(self.message)
self.log.info("Url to respond %s", URL)
```
It's not able to get the connection. But the execution API returns 200.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [I] SMTPNotifier not working on HITLBranchOperator [airflow]
Posted by "amoghrajesh (via GitHub)" <gi...@apache.org>.
amoghrajesh commented on issue #57437:
URL: https://github.com/apache/airflow/issues/57437#issuecomment-3461635719
Yeah, I do not see the reported error too, I see this:
```shell script
[2025-10-29 19:17:32] ERROR - Task failed with exception source=task loc=task_runner.py:996
AirflowException: SMTP connection is not found.
File "/opt/airflow/task-sdk/src/airflow/sdk/execution_time/task_runner.py", line 934 in run
File "/opt/airflow/task-sdk/src/airflow/sdk/execution_time/task_runner.py", line 1331 in _execute_task
File "/opt/airflow/task-sdk/src/airflow/sdk/bases/operator.py", line 416 in wrapper
File "/opt/airflow/providers/standard/src/airflow/providers/standard/operators/hitl.py", line 152 in execute
File "/opt/airflow/task-sdk/src/airflow/sdk/bases/notifier.py", line 138 in __call__
File "/opt/airflow/providers/smtp/src/airflow/providers/smtp/notifications/smtp.py", line 152 in notify
File "/opt/airflow/providers/smtp/src/airflow/providers/smtp/hooks/smtp.py", line 80 in __enter__
File "/opt/airflow/providers/smtp/src/airflow/providers/smtp/hooks/smtp.py", line 120 in get_conn
AirflowNotFoundException: The conn_id `smtp_default` isn't defined
File "/opt/airflow/providers/smtp/src/airflow/providers/smtp/hooks/smtp.py", line 118 in get_conn
File "/opt/airflow/task-sdk/src/airflow/sdk/bases/hook.py", line 61 in get_connection
File "/opt/airflow/task-sdk/src/airflow/sdk/definitions/connection.py", line 225 in get
File "/opt/airflow/task-sdk/src/airflow/sdk/execution_time/context.py", line 175 in _get_connection
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@airflow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org