uranusjr commented on code in PR #29711:
URL: https://github.com/apache/airflow/pull/29711#discussion_r1130520722


##########
airflow/api_connexion/endpoints/variable_endpoint.py:
##########
@@ -103,15 +110,15 @@ def patch_variable(*, variable_key: str, update_mask: 
UpdateMask = None) -> Resp
 
     if data["key"] != variable_key:
         raise BadRequest("Invalid post body", detail="key from request body 
doesn't match uri parameter")
-
+    non_update_fields = ["key"]
+    variable = session.query(Variable).filter_by(key=variable_key).first()
     if update_mask:
-        if "key" in update_mask:
-            raise BadRequest("key is a ready only field")
-        if "value" not in update_mask:
-            raise BadRequest("No field to update")
-
-    Variable.set(data["key"], data["val"])
-    return variable_schema.dump(data)
+        data = extract_update_mask_data(update_mask, non_update_fields, data)
+    for key, val in data.items():
+        setattr(variable, key, val)
+    session.add(variable)
+    session.commit()

Review Comment:
   Don’t need this, the session is comitted when the function returns.



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