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


##########
airflow-core/src/airflow/api_fastapi/core_api/routes/public/connections.py:
##########
@@ -187,29 +190,20 @@ def patch_connection(
             "The connection_id in the request body does not match the URL 
parameter",
         )
 
-    non_update_fields = {"connection_id", "conn_id"}
-    connection = 
session.scalar(select(Connection).filter_by(conn_id=connection_id).limit(1))
+    connection: Connection = 
session.scalar(select(Connection).filter_by(conn_id=connection_id).limit(1))
 
     if connection is None:
         raise HTTPException(
             status.HTTP_404_NOT_FOUND, f"The Connection with connection_id: 
`{connection_id}` was not found"
         )
 
-    fields_to_update = patch_body.model_fields_set
-
-    if update_mask:
-        fields_to_update = fields_to_update.intersection(update_mask)
-    else:
-        try:
-            ConnectionBody(**patch_body.model_dump())
-        except ValidationError as e:
-            raise RequestValidationError(errors=e.errors())
-
-    data = patch_body.model_dump(include=fields_to_update - non_update_fields, 
by_alias=True)
-
-    for key, val in data.items():
-        setattr(connection, key, val)
+    try:
+        ConnectionBody(**patch_body.model_dump())
+    except ValidationError as e:
+        raise RequestValidationError(errors=e.errors())

Review Comment:
   I can not move this into `update_orm_from_pydantic` - I also wanted to - 
because in the batch handling there is directly a ValidationError raised which 
is catched to loop over other records, In the normal patch a 
RequestValidationError is raised which then directly raises a HTTP error 
response..



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