jason810496 commented on code in PR #76458:
URL: https://github.com/apache/airflow/pull/76458#discussion_r4755776696


##########
airflow-ctl/src/airflowctl/api/operations.py:
##########
@@ -630,13 +631,18 @@ def update(
 
     def test(
         self,
-        connection: ConnectionBody,
+        connection: ConnectionTestBody,
     ) -> ConnectionTestResponse | ServerResponseError:
-        """Test a connection."""
-        self.response = self.client.post(
-            "connections/test",
-            json=connection.model_dump(mode="json", by_alias=True, 
exclude_none=True),
-        )
+        """
+        Test a connection.
+
+        With only ``connection_id`` (and maybe ``team_name``) set, the server 
tests the stored
+        connection. Otherwise it tests exactly this connection, so the fields 
left unset are sent as null.
+        """
+        body = connection.model_dump(mode="json", by_alias=True, 
exclude_none=True)
+        if not body.keys() <= {"connection_id", "team_name"}:

Review Comment:
   Passing `--conn-type` with only an id now tests a connection whose other 
fields are all null. Should the client reject that?
   
   ```suggestion
           if "conn_type" in body and body.keys() <= {"connection_id", 
"team_name", "conn_type"}:
               raise ValueError(
                   "Send only connection_id to test the stored connection, or 
the full connection to test."
               )
           if not body.keys() <= {"connection_id", "team_name"}:
   ```



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to