Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 0 additions & 6 deletions task-sdk/src/airflow/sdk/definitions/connection.py
Original file line number Diff line number Diff line change
Expand Up @@ -293,12 +293,6 @@ def to_dict(self, *, prune_empty: bool = False, validate: bool = True) -> dict[s
@classmethod
def from_json(cls, value, conn_id=None) -> Connection:
kwargs = json.loads(value)
conn_type = kwargs.get("conn_type", None)
if not conn_type:
raise ValueError(
"Connection type (conn_type) is required but missing from connection configuration. "
"Please add 'conn_type' field to your connection definition."
)
extra = kwargs.pop("extra", None)
if extra:
kwargs["extra"] = extra if isinstance(extra, str) else json.dumps(extra)
Expand Down
17 changes: 0 additions & 17 deletions task-sdk/tests/task_sdk/definitions/test_connection.py
Original file line number Diff line number Diff line change
Expand Up @@ -190,23 +190,6 @@ def test_from_json(self):
assert connection.host == "localhost"
assert connection.port == 5432

def test_from_json_missing_conn_type(self):
"""Test that missing conn_type throws an error while using from_json."""
import re

json_data = {
"host": "localhost",
"port": "5432",
}

with pytest.raises(
ValueError,
match=re.escape(
"Connection type (conn_type) is required but missing from connection configuration. Please add 'conn_type' field to your connection definition."
),
):
Connection.from_json(json.dumps(json_data), conn_id="test_conn")

def test_extra_dejson_property(self):
"""Test that extra_dejson property correctly deserializes JSON extra field."""
connection = Connection(
Expand Down