Re: [I] airflow.exceptions.AirflowException: The smtp connection should be loaded before! [airflow]
shahar1 commented on issue #49920: URL: https://github.com/apache/airflow/issues/49920#issuecomment-3890212818 > Damn, I've found a bug: [this](https://github.com/apache/airflow/blob/f2d4eef16cc43d68908fd67c6632d8b97d4c3e63/providers/smtp/src/airflow/providers/smtp/hooks/smtp.py#L121) loop inside the `get_conn()` method isn't entered when `self.smtp_retry_limit == 0` (in the Web UI, I set "Number of Retries" to zero in order to better check connection problems). BUT! Here is another bug which added a headache to me: for some reason, the Web UI shows "Number of Retries" as 5 (instead of 0)! Since I forgot that I had set it to 0, I thought it was 5... > > In order to fix the first bug, it seems enough just to set the `range()` to start at 0 (since `self.smtp_retry_limit` is a number of **re**tries = repeated tries after the first try). Should I open a PR, @shahar1? > And I look forward to any thoughts regarding the second bug (I'm very bad at frontend). Please go ahead! It's better to continue the discussion on an open PR. -- 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: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
Re: [I] airflow.exceptions.AirflowException: The smtp connection should be loaded before! [airflow]
TopCoder2K commented on issue #49920: URL: https://github.com/apache/airflow/issues/49920#issuecomment-3889946204 Damn, I've found a bug: [this](https://github.com/apache/airflow/blob/f2d4eef16cc43d68908fd67c6632d8b97d4c3e63/providers/smtp/src/airflow/providers/smtp/hooks/smtp.py#L121) loop inside the `get_conn()` method isn't entered when `self.smtp_retry_limit == 0` (in the Web UI, I set "Number of Retries" to zero in order to better check connection problems). BUT! Here is another bug which added a headache to me: for some reason, the Web UI shows "Number of Retries" as 5 (instead of 0)! Since I forgot that I had set it to 0, I thought it was 5... In order to fix the first bug, it seems enough just to set the `range()` to start at 0 (since `self.smtp_retry_limit` is a number of **re**tries = repeated tries after the first try). Should I open a PR, @shahar1? And I look forward to any thoughts regarding the second bug (I'm very bad at frontend). -- 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: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
Re: [I] airflow.exceptions.AirflowException: The smtp connection should be loaded before! [airflow]
shahar1 commented on issue #49920:
URL: https://github.com/apache/airflow/issues/49920#issuecomment-3889427749
> @shahar1, oh, yes, I should have done it before you answered. Here is the
simplest Dag built using the docs
([this](https://airflow.apache.org/docs/apache-airflow-providers-smtp/stable/_api/airflow/providers/smtp/notifications/smtp/index.html#airflow.providers.smtp.notifications.smtp.SmtpNotifier)
and
[this](https://airflow.apache.org/docs/apache-airflow-providers-smtp/stable/notifications/smtp_notifier_howto_guide.html))
(the real emails are replaced):
> ```python
> from airflow.decorators import dag, task
> from airflow.providers.smtp.notifications.smtp import SmtpNotifier
>
>
> @dag(
> schedule=None,
> default_args={
> "on_failure_callback": [
> SmtpNotifier(
> to="to_email",
> from_email="from_email",
> subject="[Error] The task {{ ti.task_id }} failed",
> html_content="Link to the logs: {{ ti.log_url }}",
> )
> ]
> },
> )
> def test_smtp_notification():
> @task
> def failing_task():
> raise RuntimeError("Error!")
>
> failing_task()
>
>
> test_smtp_notification()
> ```
> Here are the logs:
> ```bash
> 2026-02-12, 07:59:28 UTC] {taskinstance.py:3336} ERROR - Task failed with
exception
> Traceback (most recent call last):
> File
"/home/airflow/.local/lib/python3.12/site-packages/airflow/models/taskinstance.py",
line 776, in _execute_task
> result = _execute_callable(context=context, **execute_callable_kwargs)
> ^
> File
"/home/airflow/.local/lib/python3.12/site-packages/airflow/models/taskinstance.py",
line 742, in _execute_callable
> return ExecutionCallableRunner(
>
> File
"/home/airflow/.local/lib/python3.12/site-packages/airflow/utils/operator_helpers.py",
line 252, in run
> return self.func(*args, **kwargs)
>^^
> File
"/home/airflow/.local/lib/python3.12/site-packages/airflow/models/baseoperator.py",
line 424, in wrapper
> return func(self, *args, **kwargs)
>^^^
> File
"/home/airflow/.local/lib/python3.12/site-packages/airflow/decorators/base.py",
line 266, in execute
> return_value = super().execute(context)
>
> File
"/home/airflow/.local/lib/python3.12/site-packages/airflow/models/baseoperator.py",
line 424, in wrapper
> return func(self, *args, **kwargs)
>^^^
> File
"/home/airflow/.local/lib/python3.12/site-packages/airflow/operators/python.py",
line 238, in execute
> return_value = self.execute_callable()
>^^^
> File
"/home/airflow/.local/lib/python3.12/site-packages/airflow/operators/python.py",
line 256, in execute_callable
> return runner.run(*self.op_args, **self.op_kwargs)
>^^^
> File
"/home/airflow/.local/lib/python3.12/site-packages/airflow/utils/operator_helpers.py",
line 252, in run
> return self.func(*args, **kwargs)
>^^
> File "/opt/airflow/dags/test_smtp_notification.py", line 21, in
failing_task
> raise RuntimeError("Error!")
> RuntimeError: Error!
> [2026-02-12, 07:59:28 UTC] {taskinstance.py:1242} INFO - Marking task as
FAILED. dag_id=test_smtp_notification, task_id=failing_task,
run_id=manual__2026-02-12T07:59:27.575809+00:00,
execution_date=20260212T075927, start_date=20260212T075928,
end_date=20260212T075928
> [2026-02-12, 07:59:28 UTC] {taskinstance.py:1580} INFO - Executing
callback at index 0: SmtpNotifier
> [2026-02-12, 07:59:28 UTC] {base.py:84} INFO - Retrieving connection
'smtp_default'
> [2026-02-12, 07:59:28 UTC] {basenotifier.py:109} ERROR - Failed to send
notification: 'NoneType' object has no attribute 'close'
> Traceback (most recent call last):
> File
"/home/airflow/.local/lib/python3.12/site-packages/airflow/models/taskinstance.py",
line 282, in _run_raw_task
> TaskInstance._execute_task_with_callbacks(
> File
"/home/airflow/.local/lib/python3.12/site-packages/airflow/models/taskinstance.py",
line 3184, in _execute_task_with_callbacks
> result = self._execute_task(context, task_orig)
> ^^
> File
"/home/airflow/.local/lib/python3.12/site-packages/airflow/models/taskinstance.py",
line 3208, in _execute_task
> return _execute_task(self, context, task_orig)
>^^^
> File
"/home/airflow/.local/lib/
Re: [I] airflow.exceptions.AirflowException: The smtp connection should be loaded before! [airflow]
TopCoder2K commented on issue #49920:
URL: https://github.com/apache/airflow/issues/49920#issuecomment-3889407614
@shahar1, oh, yes, I should have done it before you answered. Here is the
simplest Dag built using the docs
([this](https://airflow.apache.org/docs/apache-airflow-providers-smtp/stable/_api/airflow/providers/smtp/notifications/smtp/index.html#airflow.providers.smtp.notifications.smtp.SmtpNotifier)
and
[this](https://airflow.apache.org/docs/apache-airflow-providers-smtp/stable/notifications/smtp_notifier_howto_guide.html))
(the real emails are replaced):
```python
from airflow.decorators import dag, task
from airflow.providers.smtp.notifications.smtp import SmtpNotifier
@dag(
schedule=None,
default_args={
"on_failure_callback": [
SmtpNotifier(
to="to_email",
from_email="from_email",
subject="[Error] The task {{ ti.task_id }} failed",
html_content="Link to the logs: {{ ti.log_url }}",
)
]
},
)
def test_smtp_notification():
@task
def failing_task():
raise RuntimeError("Error!")
failing_task()
test_smtp_notification()
```
Here are the logs:
```bash
2026-02-12, 07:59:28 UTC] {taskinstance.py:3336} ERROR - Task failed with
exception
Traceback (most recent call last):
File
"/home/airflow/.local/lib/python3.12/site-packages/airflow/models/taskinstance.py",
line 776, in _execute_task
result = _execute_callable(context=context, **execute_callable_kwargs)
^
File
"/home/airflow/.local/lib/python3.12/site-packages/airflow/models/taskinstance.py",
line 742, in _execute_callable
return ExecutionCallableRunner(
File
"/home/airflow/.local/lib/python3.12/site-packages/airflow/utils/operator_helpers.py",
line 252, in run
return self.func(*args, **kwargs)
^^
File
"/home/airflow/.local/lib/python3.12/site-packages/airflow/models/baseoperator.py",
line 424, in wrapper
return func(self, *args, **kwargs)
^^^
File
"/home/airflow/.local/lib/python3.12/site-packages/airflow/decorators/base.py",
line 266, in execute
return_value = super().execute(context)
File
"/home/airflow/.local/lib/python3.12/site-packages/airflow/models/baseoperator.py",
line 424, in wrapper
return func(self, *args, **kwargs)
^^^
File
"/home/airflow/.local/lib/python3.12/site-packages/airflow/operators/python.py",
line 238, in execute
return_value = self.execute_callable()
^^^
File
"/home/airflow/.local/lib/python3.12/site-packages/airflow/operators/python.py",
line 256, in execute_callable
return runner.run(*self.op_args, **self.op_kwargs)
^^^
File
"/home/airflow/.local/lib/python3.12/site-packages/airflow/utils/operator_helpers.py",
line 252, in run
return self.func(*args, **kwargs)
^^
File "/opt/airflow/dags/test_smtp_notification.py", line 21, in
failing_task
raise RuntimeError("Error!")
RuntimeError: Error!
[2026-02-12, 07:59:28 UTC] {taskinstance.py:1242} INFO - Marking task as
FAILED. dag_id=test_smtp_notification, task_id=failing_task,
run_id=manual__2026-02-12T07:59:27.575809+00:00,
execution_date=20260212T075927, start_date=20260212T075928,
end_date=20260212T075928
[2026-02-12, 07:59:28 UTC] {taskinstance.py:1580} INFO - Executing callback
at index 0: SmtpNotifier
[2026-02-12, 07:59:28 UTC] {base.py:84} INFO - Retrieving connection
'smtp_default'
[2026-02-12, 07:59:28 UTC] {basenotifier.py:109} ERROR - Failed to send
notification: 'NoneType' object has no attribute 'close'
Traceback (most recent call last):
File
"/home/airflow/.local/lib/python3.12/site-packages/airflow/models/taskinstance.py",
line 282, in _run_raw_task
TaskInstance._execute_task_with_callbacks(
File
"/home/airflow/.local/lib/python3.12/site-packages/airflow/models/taskinstance.py",
line 3184, in _execute_task_with_callbacks
result = self._execute_task(context, task_orig)
^^
File
"/home/airflow/.local/lib/python3.12/site-packages/airflow/models/taskinstance.py",
line 3208, in _execute_task
return _execute_task(self, context, task_orig)
^^^
File
"/home/airflow/.local/lib/python3.12/site-packages/airflow/models/taskinstance.py",
line 776, in _execute_task
result = _execute_callable(context=context, **execute_call
Re: [I] airflow.exceptions.AirflowException: The smtp connection should be loaded before! [airflow]
shahar1 commented on issue #49920: URL: https://github.com/apache/airflow/issues/49920#issuecomment-3885958643 > Upgrading to `apache-airflow-providers-smtp=2.4.2` (latest) doesn't help. How to use `SmtpNotifier` (`send_smtp_notification`) 🤔? Could you please describe in detail what issue you encounter after upgrading? (including code sample of a Dag, logs, anything that could help debugging this issue) -- 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: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
Re: [I] airflow.exceptions.AirflowException: The smtp connection should be loaded before! [airflow]
TopCoder2K commented on issue #49920: URL: https://github.com/apache/airflow/issues/49920#issuecomment-3884950657 Upgrading to `apache-airflow-providers-smtp=2.4.2` (latest) doesn't help. How to use `SmtpNotifier` (`send_smtp_notification`) 🤔? -- 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: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
Re: [I] airflow.exceptions.AirflowException: The smtp connection should be loaded before! [airflow]
TopCoder2K commented on issue #49920: URL: https://github.com/apache/airflow/issues/49920#issuecomment-3884095515 I'm also experiencing the same problem with `Airflow=2.11.0` and `apache-airflow-providers-smtp=2.1.0`. Does this mean that the official docker image is incorrect and I should upgrade `apache-airflow-providers-smtp` (I cannot upgrade Airflow)? -- 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: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
Re: [I] airflow.exceptions.AirflowException: The smtp connection should be loaded before! [airflow]
shahar1 closed issue #49920: airflow.exceptions.AirflowException: The smtp connection should be loaded before! URL: https://github.com/apache/airflow/issues/49920 -- 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: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
Re: [I] airflow.exceptions.AirflowException: The smtp connection should be loaded before! [airflow]
m-rossi commented on issue #49920: URL: https://github.com/apache/airflow/issues/49920#issuecomment-3078448560 Had the same issue also on 3.0.3 and just submitted a fix in #53418, however in my local tests I am next stuck in #53135. -- 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: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
Re: [I] airflow.exceptions.AirflowException: The smtp connection should be loaded before! [airflow]
potiuk commented on issue #49920: URL: https://github.com/apache/airflow/issues/49920#issuecomment-2993694665 can you show the longs and explain in details what you've done for 3.0.2 @IIPOCTAK ? -- 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: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
Re: [I] airflow.exceptions.AirflowException: The smtp connection should be loaded before! [airflow]
IIPOCTAK commented on issue #49920: URL: https://github.com/apache/airflow/issues/49920#issuecomment-2967112136 Same problem with Airflow 3.0.2 version and apache-airflow-providers-smtp 2.1.0 version. Tried set connection using `AIRFLOW_CONN_*` env variable and after through web UI. -- 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: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
Re: [I] airflow.exceptions.AirflowException: The smtp connection should be loaded before! [airflow]
ForeverWintr commented on issue #49920: URL: https://github.com/apache/airflow/issues/49920#issuecomment-2963975863 I see this issue in 2.11 also. -- 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: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
Re: [I] airflow.exceptions.AirflowException: The smtp connection should be loaded before! [airflow]
boring-cyborg[bot] commented on issue #49920: URL: https://github.com/apache/airflow/issues/49920#issuecomment-2836991889 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: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
