SameerMesiah97 commented on code in PR #62657:
URL: https://github.com/apache/airflow/pull/62657#discussion_r2871612532


##########
airflow-core/src/airflow/api_fastapi/core_api/routes/public/connections.py:
##########
@@ -203,8 +203,12 @@ def patch_connection(
             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)
+
     try:
-        ConnectionBody(**patch_body.model_dump())
+        ConnectionBody(**patch_body.model_dump(include=fields_to_update))

Review Comment:
   As evidenced bythe CI failures, it looks like you are validating only the 
subset of fields being updated against the full `ConnectionBody` model. Since 
`ConnectionBody` has required fields (e.g. `conn_type`), partial patch payloads 
now fail validation.
   
   I think we may need to retrieve the existing model, merge the patch data, 
and then validate the merged result instead.



##########
airflow-core/src/airflow/api_fastapi/core_api/services/public/variables.py:
##########
@@ -65,11 +65,15 @@ def update_orm_from_pydantic(
             status.HTTP_404_NOT_FOUND, f"The Variable with key: 
`{variable_key}` was not found"
         )
 
+    non_update_fields = {"key"}
+    fields_to_update = patch_body.model_fields_set
+    if update_mask:
+        fields_to_update = fields_to_update.intersection(update_mask)
+
     try:
-        VariableBody(**patch_body.model_dump())
+        VariableBody(**patch_body.model_dump(include=fields_to_update))
     except ValidationError as e:
         raise RequestValidationError(errors=e.errors())

Review Comment:
   Above comment applies here as well.



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