diff --git a/airflow-core/src/airflow/jobs/triggerer_job_runner.py b/airflow-core/src/airflow/jobs/triggerer_job_runner.py index adc87e802fa6f..8d2bdf99795e0 100644 --- a/airflow-core/src/airflow/jobs/triggerer_job_runner.py +++ b/airflow-core/src/airflow/jobs/triggerer_job_runner.py @@ -396,7 +396,8 @@ def _handle_request(self, msg: ToTriggerSupervisor, log: FilteringBoundLogger, r if isinstance(conn, ConnectionResponse): conn_result = ConnectionResult.from_conn_response(conn) resp = conn_result - dump_opts = {"exclude_unset": True} + # `by_alias=True` is used to convert the `schema` field to `schema_` in the Connection model + dump_opts = {"exclude_unset": True, "by_alias": True} else: resp = conn elif isinstance(msg, GetVariable): diff --git a/airflow-core/tests/unit/jobs/test_triggerer_job.py b/airflow-core/tests/unit/jobs/test_triggerer_job.py index d3cecb5fc94e6..08e08f08c4fcb 100644 --- a/airflow-core/tests/unit/jobs/test_triggerer_job.py +++ b/airflow-core/tests/unit/jobs/test_triggerer_job.py @@ -645,7 +645,16 @@ async def test_trigger_can_access_variables_connections_and_xcoms(session, dag_m task_instance.trigger_id = trigger_orm.id # Create the appropriate Connection, Variable and XCom - connection = Connection(conn_id="test_connection", conn_type="http") + connection = Connection( + conn_id="test_connection", + conn_type="http", + schema="https", + login="user", + password="pass", + extra={"key": "value"}, + port=443, + host="example.com", + ) variable = Variable(key="test_variable", val="some_variable_value") XComModel.set( key="test_xcom", @@ -675,12 +684,12 @@ async def test_trigger_can_access_variables_connections_and_xcoms(session, dag_m "conn_id": "test_connection", "conn_type": "http", "description": None, - "host": None, - "schema": None, - "login": None, - "password": None, - "port": None, - "extra": None, + "host": "example.com", + "schema": "https", + "login": "user", + "password": "pass", + "port": 443, + "extra": '{"key": "value"}', }, "variable": "some_variable_value", "xcom": '"some_xcom_value"',