Brunda10 commented on code in PR #54597:
URL: https://github.com/apache/airflow/pull/54597#discussion_r2287948224


##########
airflow-core/src/airflow/api_fastapi/core_api/services/public/variables.py:
##########
@@ -94,18 +96,29 @@ def handle_bulk_update(self, action: BulkUpdateAction, 
results: BulkActionRespon
                 update_keys = to_update_keys
 
             for variable in action.entities:
-                if variable.key in update_keys:
-                    old_variable = 
self.session.scalar(select(Variable).filter_by(key=variable.key).limit(1))
+                if variable.key not in update_keys:
+                    continue
+                old_variable = 
self.session.scalar(select(Variable).filter_by(key=variable.key).limit(1))
+                if not old_variable:
+                    continue  # shouldn't happen because we filtered above
+
+                fields_to_update = variable.model_fields_set
+                if update_mask:
+                    print(f"Update mask provided: {update_mask}")
+                    # Only keep fields in update_mask
+                    fields_to_update = 
fields_to_update.intersection(update_mask)
+                else:
                     VariableBody(**variable.model_dump())
-                    data = variable.model_dump(exclude={"key"}, by_alias=True)
 
-                    for key, val in data.items():
-                        setattr(old_variable, key, val)
-                    results.success.append(variable.key)
+                data = variable.model_dump(include=fields_to_update - 
non_update_fields, by_alias=True)
+                # Apply updates

Review Comment:
   Sure we will create common utility function to handle patching for 
Pools,Variables. Should this function support both single PATCH endpoints and 
bulk PATCH actions using update_mask, or just the bulk updates?



-- 
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: commits-unsubscr...@airflow.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to