pierrejeambrun commented on code in PR #48109:
URL: https://github.com/apache/airflow/pull/48109#discussion_r2016706449


##########
airflow-core/src/airflow/api_fastapi/core_api/services/public/connections.py:
##########
@@ -108,12 +129,17 @@ def handle_bulk_update(
 
             for connection in action.entities:
                 if connection.connection_id in update_connection_ids:
-                    old_connection = self.session.scalar(
+                    old_connection: Connection = self.session.scalar(
                         select(Connection).filter(Connection.conn_id == 
connection.connection_id).limit(1)
                     )
+                    if old_connection is None:
+                        raise ValidationError(
+                            f"The Connection with connection_id: 
`{connection.connection_id}` was not found"
+                        )
                     ConnectionBody(**connection.model_dump())
-                    for key, val in 
connection.model_dump(by_alias=True).items():
-                        setattr(old_connection, key, val)
+
+                    # Not all fields match and some need setters, therefore 
copy manually

Review Comment:
   I think we can remove this comment, it's part of the 
`update_orm_from_pydantic` fn now.



##########
airflow-core/tests/unit/api_fastapi/core_api/routes/public/test_connections.py:
##########
@@ -390,7 +401,13 @@ def test_should_respond_403(self, 
unauthorized_test_client):
         "body, updated_connection, update_mask",
         [
             (
-                {"connection_id": TEST_CONN_ID, "conn_type": TEST_CONN_TYPE, 
"extra": '{"key": "var"}'},
+                {
+                    "connection_id": TEST_CONN_ID,
+                    "conn_type": TEST_CONN_TYPE,
+                    "extra": '{"key": "var"}',
+                    "login": TEST_CONN_LOGIN,
+                    "port": TEST_CONN_PORT,
+                },

Review Comment:
   It seems that with this change we cannot explicitely set to `None`. (insert 
a None value on purpose)



-- 
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