You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by "drewrukin (via GitHub)" <gi...@apache.org> on 2026/10/04 10:05:20 UTC
[PR] Cache SMTP clients only after setup succeeds [airflow]
drewrukin opened a new pull request, #74185:
URL: https://github.com/apache/airflow/pull/74185
Failed SMTP setup leaves a partially initialized client available for reuse. Cache synchronous and asynchronous clients only after setup and authentication succeed. Close failed clients while preserving the original exception, including failures during async connection creation.
Add regression tests for synchronous and asynchronous setup failures, cleanup and successful reconnection.
---
##### Was generative AI tooling used to co-author this PR?
- [x] Yes — Codex (GPT-6)
Generated-by: Codex (GPT-6) following [the guidelines](https://github.com/apache/airflow/blob/main/contributing-docs/05_pull_requests.rst#gen-ai-assisted-contributions)
--
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: [PR] Cache SMTP clients only after setup succeeds [airflow]
Posted by "shivaam (via GitHub)" <gi...@apache.org>.
shivaam commented on code in PR #74185:
URL: https://github.com/apache/airflow/pull/74185#discussion_r4349754299
##########
providers/smtp/tests/unit/smtp/hooks/test_smtp.py:
##########
@@ -720,6 +753,61 @@ async def test_async_connection(
assert mock_smtp_client.auth_login.await_count == 1
mock_smtp_client.auth_login.assert_awaited_once_with(SMTP_LOGIN, SMTP_PASSWORD)
+ @pytest.mark.parametrize("failed_step", ["starttls", "ehlo", "auth_login", "auth_xoauth2"])
+ @pytest.mark.parametrize("cleanup_fails", [False, True])
+ async def test_discards_failed_setup(self, mock_get_connection, failed_step, cleanup_fails):
+ failed_client = mock.create_autospec(aiosmtplib.SMTP, instance=True)
+ healthy_client = mock.create_autospec(aiosmtplib.SMTP, instance=True)
+ for client in (failed_client, healthy_client):
+ client.auth_login = AsyncMock()
+ client.auth_xoauth2 = AsyncMock()
+ setup_error = OSError("setup failed")
Review Comment:
Nonblocking nit: could we also cover `asyncio.CancelledError` here and in the `_abuild_client` failure tests? The `OSError` cases exercise cleanup, but would still pass if `except BaseException` were narrowed to `except Exception`. A cancellation case would protect closing the client and propagating the original cancellation.
---
Drafted-by: Codex (no human review of this comment text before posting)
--
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: [PR] Cache SMTP clients only after setup succeeds [airflow]
Posted by "shivaam (via GitHub)" <gi...@apache.org>.
shivaam commented on code in PR #74185:
URL: https://github.com/apache/airflow/pull/74185#discussion_r4349754299
##########
providers/smtp/tests/unit/smtp/hooks/test_smtp.py:
##########
@@ -720,6 +753,61 @@ async def test_async_connection(
assert mock_smtp_client.auth_login.await_count == 1
mock_smtp_client.auth_login.assert_awaited_once_with(SMTP_LOGIN, SMTP_PASSWORD)
+ @pytest.mark.parametrize("failed_step", ["starttls", "ehlo", "auth_login", "auth_xoauth2"])
+ @pytest.mark.parametrize("cleanup_fails", [False, True])
+ async def test_discards_failed_setup(self, mock_get_connection, failed_step, cleanup_fails):
+ failed_client = mock.create_autospec(aiosmtplib.SMTP, instance=True)
+ healthy_client = mock.create_autospec(aiosmtplib.SMTP, instance=True)
+ for client in (failed_client, healthy_client):
+ client.auth_login = AsyncMock()
+ client.auth_xoauth2 = AsyncMock()
+ setup_error = OSError("setup failed")
Review Comment:
Nonblocking nit: could we also cover `asyncio.CancelledError` here and in the `_abuild_client` failure tests? The `OSError` cases exercise cleanup, but would still pass if `except BaseException` were narrowed to `except Exception`. A cancellation case would protect closing the client and propagating the original cancellation.
---
Drafted-by: Codex (reviewed locally)
--
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: [PR] Cache SMTP clients only after setup succeeds [airflow]
Posted by "drewrukin (via GitHub) via commits" <co...@airflow.apache.org>.
drewrukin commented on PR #74185:
URL: https://github.com/apache/airflow/pull/74185#issuecomment-6736112859
Thank you for the review. The cancellation cases are now covered, the branch has been rebased, and the SMTP/provider checks pass. The remaining static failure is an unrelated HTTP 504 while downloading `kind`. Could you please take another look when convenient?
--
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: [PR] Cache SMTP clients only after setup succeeds [airflow]
Posted by "drewrukin (via GitHub) via commits" <co...@airflow.apache.org>.
drewrukin commented on code in PR #74185:
URL: https://github.com/apache/airflow/pull/74185#discussion_r4505686107
##########
providers/smtp/tests/unit/smtp/hooks/test_smtp.py:
##########
@@ -720,6 +753,61 @@ async def test_async_connection(
assert mock_smtp_client.auth_login.await_count == 1
mock_smtp_client.auth_login.assert_awaited_once_with(SMTP_LOGIN, SMTP_PASSWORD)
+ @pytest.mark.parametrize("failed_step", ["starttls", "ehlo", "auth_login", "auth_xoauth2"])
+ @pytest.mark.parametrize("cleanup_fails", [False, True])
+ async def test_discards_failed_setup(self, mock_get_connection, failed_step, cleanup_fails):
+ failed_client = mock.create_autospec(aiosmtplib.SMTP, instance=True)
+ healthy_client = mock.create_autospec(aiosmtplib.SMTP, instance=True)
+ for client in (failed_client, healthy_client):
+ client.auth_login = AsyncMock()
+ client.auth_xoauth2 = AsyncMock()
+ setup_error = OSError("setup failed")
Review Comment:
Handled in 686548ece8: added asyncio.CancelledError coverage to both async setup-failure tests, including cleanup failures. The assertions protect client cleanup and propagation of the original cancellation. The branch is rebased onto current main; the focused SMTP tests and the required Breeze test suites pass.
---
Drafted-by: Codex (GPT-5) (no human review before posting)
--
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: [PR] Cache SMTP clients only after setup succeeds [airflow]
Posted by "eladkal (via GitHub)" <gi...@apache.org>.
eladkal commented on code in PR #74185:
URL: https://github.com/apache/airflow/pull/74185#discussion_r4409930379
##########
providers/smtp/tests/unit/smtp/hooks/test_smtp.py:
##########
@@ -720,6 +753,61 @@ async def test_async_connection(
assert mock_smtp_client.auth_login.await_count == 1
mock_smtp_client.auth_login.assert_awaited_once_with(SMTP_LOGIN, SMTP_PASSWORD)
+ @pytest.mark.parametrize("failed_step", ["starttls", "ehlo", "auth_login", "auth_xoauth2"])
+ @pytest.mark.parametrize("cleanup_fails", [False, True])
+ async def test_discards_failed_setup(self, mock_get_connection, failed_step, cleanup_fails):
+ failed_client = mock.create_autospec(aiosmtplib.SMTP, instance=True)
+ healthy_client = mock.create_autospec(aiosmtplib.SMTP, instance=True)
+ for client in (failed_client, healthy_client):
+ client.auth_login = AsyncMock()
+ client.auth_xoauth2 = AsyncMock()
+ setup_error = OSError("setup failed")
Review Comment:
@drewrukin can you handle this?
--
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