ajitg25 commented on code in PR #44619:
URL: https://github.com/apache/airflow/pull/44619#discussion_r1871629530


##########
airflow/api_fastapi/core_api/routes/public/variables.py:
##########
@@ -130,14 +132,24 @@ def patch_variable(
         raise HTTPException(
             status.HTTP_404_NOT_FOUND, f"The Variable with key: 
`{variable_key}` was not found"
         )
+
+    fields_to_update = patch_body.model_fields_set
     if update_mask:
+        fields_to_update = fields_to_update.intersection(update_mask)
         data = patch_body.model_dump(
-            include=set(update_mask) - non_update_fields, by_alias=True, 
exclude_none=True
+            include=fields_to_update - non_update_fields, by_alias=True, 
exclude_none=True
         )
     else:
+        try:
+            VariableBody(**patch_body.model_dump())
+        except ValidationError as e:
+            raise RequestValidationError(errors=e.errors())
         data = patch_body.model_dump(exclude=non_update_fields, by_alias=True, 
exclude_none=True)
+
     for key, val in data.items():
         setattr(variable, key, val)
+
+    session.commit()

Review Comment:
   Okay, looks like both are not required then, if only closing the session it 
will get committed.



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