Add support to create connections using uri in SDK#62211
Merged
Conversation
1 task
uranusjr
reviewed
Feb 24, 2026
Contributor
Author
|
Some small adjustments needed to fix the CI _______________________________________________________________________ TestConnectionFromUri.test_connection_constructor_with_uri _______________________________________________________________________
[gw1] linux -- Python 3.10.19 /usr/python/bin/python
task-sdk/tests/task_sdk/definitions/test_connection.py:382: in test_connection_constructor_with_uri
conn = Connection(conn_id="test_conn", uri="**host:5432/db")
task-sdk/src/airflow/sdk/definitions/connection.py:153: in __init__
self.__dict__.update(self.from_uri(uri, conn_id=conn_id).to_dict(validate=False))
E AttributeError: 'Connection' object has no attribute '__dict__'. Did you mean: '__dir__'?Looks like I need to set |
Contributor
Author
|
LGTM but I cannot approve my own PR haha! |
uranusjr
reviewed
Feb 26, 2026
AkshayArali
pushed a commit
to AkshayArali/airflow_630
that referenced
this pull request
Feb 28, 2026
* Add support to create connections using uri in SDK * Add support to create connections using uri in SDK * Add support to create connections using uri in SDK * fixing unit tests * Allow URI without adding it as a field * fixing failing tests and mypy * remove unwanted line --------- Co-authored-by: Tzu-ping Chung <uranusjr@gmail.com>
dominikhei
pushed a commit
to dominikhei/airflow
that referenced
this pull request
Mar 11, 2026
* Add support to create connections using uri in SDK * Add support to create connections using uri in SDK * Add support to create connections using uri in SDK * fixing unit tests * Allow URI without adding it as a field * fixing failing tests and mypy * remove unwanted line --------- Co-authored-by: Tzu-ping Chung <uranusjr@gmail.com>
1 task
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Was generative AI tooling used to co-author this PR?
Why?
Happened to notice in https://github.com/apache/airflow/blob/main/providers/apache/livy/tests/unit/apache/livy/hooks/test_livy.py#L91 for example that it was allowed to create a connection in airflow 2.x with
urifield. Although we have support for it now usingfrom_urithis could mean that some DAGs from legacy base could fail due to this.So I am intending to support constructing Connection from a URI now.
I had to use
__attrs_post_init__(to avoidattrs.define(init=False)and a custom__init__to keep the class simple) to parse uri when provided and populate other fields: conn_type, host,login, password, port, schema, and extra. This is because: uri is init-only and excluded from serialization (to_dict, from_json) matching the behaviour of models.connection.
{pr_number}.significant.rstor{issue_number}.significant.rst, in airflow-core/newsfragments.