Skip to content

Commit 8ed08ef

Browse files
[v3-0-test] Fix connection retrieval in triggerer for schema field, use by_alias=True for ConnectionResult (#52673) (#52691)
* Fix connection retrieval in triggerer for schema field, use by_alias=True for ConnectionResult * Fix connection retrieval in triggerer for schema field, use by_alias=True for ConnectionResult (cherry picked from commit bb93415) Co-authored-by: GPK <[email protected]>
1 parent f61d414 commit 8ed08ef

File tree

2 files changed

+18
-8
lines changed

2 files changed

+18
-8
lines changed

airflow-core/src/airflow/jobs/triggerer_job_runner.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -396,7 +396,8 @@ def _handle_request(self, msg: ToTriggerSupervisor, log: FilteringBoundLogger, r
396396
if isinstance(conn, ConnectionResponse):
397397
conn_result = ConnectionResult.from_conn_response(conn)
398398
resp = conn_result
399-
dump_opts = {"exclude_unset": True}
399+
# `by_alias=True` is used to convert the `schema` field to `schema_` in the Connection model
400+
dump_opts = {"exclude_unset": True, "by_alias": True}
400401
else:
401402
resp = conn
402403
elif isinstance(msg, GetVariable):

airflow-core/tests/unit/jobs/test_triggerer_job.py

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -645,7 +645,16 @@ async def test_trigger_can_access_variables_connections_and_xcoms(session, dag_m
645645
task_instance.trigger_id = trigger_orm.id
646646

647647
# Create the appropriate Connection, Variable and XCom
648-
connection = Connection(conn_id="test_connection", conn_type="http")
648+
connection = Connection(
649+
conn_id="test_connection",
650+
conn_type="http",
651+
schema="https",
652+
login="user",
653+
password="pass",
654+
extra={"key": "value"},
655+
port=443,
656+
host="example.com",
657+
)
649658
variable = Variable(key="test_variable", val="some_variable_value")
650659
XComModel.set(
651660
key="test_xcom",
@@ -675,12 +684,12 @@ async def test_trigger_can_access_variables_connections_and_xcoms(session, dag_m
675684
"conn_id": "test_connection",
676685
"conn_type": "http",
677686
"description": None,
678-
"host": None,
679-
"schema": None,
680-
"login": None,
681-
"password": None,
682-
"port": None,
683-
"extra": None,
687+
"host": "example.com",
688+
"schema": "https",
689+
"login": "user",
690+
"password": "pass",
691+
"port": 443,
692+
"extra": '{"key": "value"}',
684693
},
685694
"variable": "some_variable_value",
686695
"xcom": '"some_xcom_value"',

0 commit comments

Comments
 (0)