[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_userandsmtp_passviaConnectionobject creates confusion as to source of truth for other SMTP params. This change proproses overriding allsmtp_*vars with theConnectionobject equivalents whenemail.email_conn_idis 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
Falsewhen not set, making it impossible to create a fallback condition. Attempting to implement a fallback leads to a state where thesmtp_sslconfig is ignored if the checkbox is checked, or thesmtp_sslconfig 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_idis in play.Possible solutions
[smtp]config vars duplicated by connection object. Effectively mandate that all smtp configuration is done via aConnectionobject. This requires the most changes.airflow.utils.email.send_email_smtpbackend intosend_email_smtpandsmtp_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 aConnectionobject to secure your SMTP params, you must configure the entirety of the SMTP connection using the object.smtp.smtp_config_source=config|connectionand require the user to opt into desired behaviour. Allows the user to specify that all SMTP vars should be controlled byConnectionobject. Still leaves a confusing default state.SelectField/RadioFieldtypes 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.rstor{issue_number}.significant.rst, in newsfragments.