Skip to content

Swap send_mime_email in core to use Connection instead of BaseHook - #54084

Merged
amoghrajesh merged 1 commit into
apache:mainfrom
astronomer:use-models-connection-for-email
Aug 4, 2025
Merged

Swap send_mime_email in core to use Connection instead of BaseHook#54084
amoghrajesh merged 1 commit into
apache:mainfrom
astronomer:use-models-connection-for-email

Conversation

@amoghrajesh

Copy link
Copy Markdown
Contributor

Extracted out of: #54083, to fix:

______________________________________________________________________________ TestEmailSmtp.test_send_mime_airflow_config _______________________________________________________________________________
airflow-core/tests/unit/utils/test_email.py:218: in test_send_mime_airflow_config
email.send_mime_email("from", "to", msg, dryrun=False)
airflow-core/src/airflow/utils/email.py:251: in send_mime_email
airflow_conn = BaseHook.get_connection(conn_id)
task-sdk/src/airflow/sdk/bases/hook.py:63: in get_connection
conn = Connection.get(conn_id)
task-sdk/src/airflow/sdk/definitions/connection.py:154: in get
return _get_connection(conn_id)
task-sdk/src/airflow/sdk/execution_time/context.py:153: in _get_connection
from airflow.sdk.execution_time.task_runner import SUPERVISOR_COMMS
E ImportError: cannot import name 'SUPERVISOR_COMMS' from 'airflow.sdk.execution_time.task_runner' (/opt/airflow/task-sdk/src/airflow/sdk/execution_time/task_runner.py)

The core email functionality has no reason to use BaseHook (from sdk). Swapping to use connection models. This will cut the link between sdk and core too.

Extracted out of #54083


^ Add meaningful description above
Read the Pull Request Guidelines for more information.
In case of fundamental code changes, an Airflow Improvement Proposal (AIP) is needed.
In case of a new dependency, check compliance with the ASF 3rd Party License Policy.
In case of backwards incompatible changes please leave a note in a newsfragment file, named {pr_number}.significant.rst or {issue_number}.significant.rst, in airflow-core/newsfragments.

@amoghrajeshamoghrajesh self-assigned this Aug 4, 2025
@amoghrajeshamoghrajesh added this to the Airflow 3.1.0 milestone Aug 4, 2025
@amoghrajeshamoghrajesh changed the title Swap send_mime_email to use Connection instead of BaseHookSwap send_mime_email in core to use Connection instead of BaseHookAug 4, 2025
ashb
ashb approved these changes Aug 4, 2025
Comment threadairflow-core/src/airflow/utils/email.py
@amoghrajesh
amoghrajesh merged commit e603cd8 into apache:mainAug 4, 2025
57 checks passed
@amoghrajesh
amoghrajesh deleted the use-models-connection-for-email branch August 4, 2025 11:11
ferruzzi pushed a commit to aws-mwaa/upstream-to-airflow that referenced this pull request Aug 7, 2025
fweilun pushed a commit to fweilun/airflow that referenced this pull request Aug 11, 2025
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

No open projects

Development

Successfully merging this pull request may close these issues.

2 participants

@amoghrajesh@ashb