This is an automated email from the ASF dual-hosted git repository.

henry3260 pushed a commit to branch airflow-ctl/v0-1-test
in repository https://gitbox.apache.org/repos/asf/airflow.git


The following commit(s) were added to refs/heads/airflow-ctl/v0-1-test by this 
push:
     new 89d8ac6d844 [airflow-ctl/v0-1-test] Fix airflowctl connections test 
failing on stored connections (#73098) (#73102)
89d8ac6d844 is described below

commit 89d8ac6d844e5727ac533cc87b3dca8f773178e1
Author: Henry Chen <[email protected]>
AuthorDate: Mon Sep 14 02:44:55 2026 +0800

    [airflow-ctl/v0-1-test] Fix airflowctl connections test failing on stored 
connections (#73098) (#73102)
    
    (cherry picked from commit 65eb086f40c1e95f848998dcbd1fa573387c06c9)
    
    Co-authored-by: Y-C <[email protected]>
---
 airflow-ctl/src/airflowctl/api/operations.py         |  3 ++-
 airflow-ctl/tests/airflow_ctl/api/test_operations.py | 11 ++++-------
 2 files changed, 6 insertions(+), 8 deletions(-)

diff --git a/airflow-ctl/src/airflowctl/api/operations.py 
b/airflow-ctl/src/airflowctl/api/operations.py
index 8ce25e28120..dd6608f2510 100644
--- a/airflow-ctl/src/airflowctl/api/operations.py
+++ b/airflow-ctl/src/airflowctl/api/operations.py
@@ -546,7 +546,8 @@ class ConnectionsOperations(BaseOperations):
         """Test a connection."""
         try:
             self.response = self.client.post(
-                "connections/test", json=connection.model_dump(mode="json", 
by_alias=True)
+                "connections/test",
+                json=connection.model_dump(mode="json", by_alias=True, 
exclude_none=True),
             )
             return 
ConnectionTestResponse.model_validate_json(self.response.content)
         except ServerResponseError as e:
diff --git a/airflow-ctl/tests/airflow_ctl/api/test_operations.py 
b/airflow-ctl/tests/airflow_ctl/api/test_operations.py
index a6a2145f7ff..9d6aed4e804 100644
--- a/airflow-ctl/tests/airflow_ctl/api/test_operations.py
+++ b/airflow-ctl/tests/airflow_ctl/api/test_operations.py
@@ -931,6 +931,10 @@ class TestConnectionsOperations:
         assert response == connection_test_response
 
     def test_test_uses_schema_alias_in_request_body(self):
+        # The exact body matters beyond the alias: the server fills unset 
fields from the stored
+        # connection, keyed off ``model_fields_set``. Sending them as null 
makes a stored host/port
+        # read as "changed" and the request is rejected with 400; a connection 
without a host gets
+        # tested with its credentials wiped.
         connection = ConnectionBody(
             connection_id=self.connection_id,
             conn_type=self.conn_type,
@@ -947,14 +951,7 @@ class TestConnectionsOperations:
             assert request_body == {
                 "connection_id": self.connection_id,
                 "conn_type": self.conn_type,
-                "description": None,
-                "host": None,
-                "login": None,
                 "schema": self.schema_,
-                "port": None,
-                "password": None,
-                "extra": None,
-                "team_name": None,
             }
             assert "schema_" not in request_body
             return httpx.Response(200, 
json=json.loads(connection_test_response.model_dump_json()))

Reply via email to