[WIP] Override smtp config variables with connection values specified by email_conn_id #43413
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
closes: #34554
related: #41539
WIP This change is incomplete, requires discussion.
Mandatory configuration of
smtp_user
andsmtp_pass
viaConnection
object creates confusion as to source of truth for other SMTP params. This change proproses overriding allsmtp_*
vars with theConnection
object equivalents whenemail.email_conn_id
is specified. However, this creates some a questions that need resolving/consensus.Issue 1
My preference would be to use the
[smtp]
config vars as default/fallback values. However, this isn't possible as the connection UI doesn't allow for an 'not-specified' state for certain fields.E.g. the 'Disable SSL' checkbox defaults to
False
when not set, making it impossible to create a fallback condition. Attempting to implement a fallback leads to a state where thesmtp_ssl
config is ignored if the checkbox is checked, or thesmtp_ssl
config must be set to the desired value if the checkbox is unchecked.Issue 2
[smtp]
configuration variables are become usable only for connections not requiring authentication. This effectively reverses the confusion I'm trying to address. I.e.[smtp]
config vars would have no effect ifemail_conn_id
is in play.Possible solutions
[smtp]
config vars duplicated by connection object. Effectively mandate that all smtp configuration is done via aConnection
object. This requires the most changes.airflow.utils.email.send_email_smtp
backend intosend_email_smtp
andsmtp_email_smtp_via_conn
. For this to work we'd need to revert smtp email user and password deprecated config removal #41539 and its deprecation, then auto-select backend based on presence ofemail_conn_id
. Effectively states that if you want to use aConnection
object to secure your SMTP params, you must configure the entirety of the SMTP connection using the object.smtp.smtp_config_source=config|connection
and require the user to opt into desired behaviour. Allows the user to specify that all SMTP vars should be controlled byConnection
object. Still leaves a confusing default state.SelectField/RadioField
types aren't allowed in Connection Forms^ 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 newsfragments.