amoghrajesh commented on code in PR #49107:
URL: https://github.com/apache/airflow/pull/49107#discussion_r2039096538


##########
airflow-core/src/airflow/models/variable.py:
##########
@@ -225,18 +219,20 @@ def set(
             )
             return
 
+        # check if the secret exists in the custom secrets' backend.
+        Variable.check_for_write_conflict(key=key)
         if serialize_json:
             stored_value = json.dumps(value, indent=2)
         else:
             stored_value = str(value)
-
-        Variable.delete(key, session=session)
-        session.add(Variable(key=key, val=stored_value, 
description=description))
-        session.flush()
-        # invalidate key in cache for faster propagation
-        # we cannot save the value set because it's possible that it's 
shadowed by a custom backend
-        # (see call to check_for_write_conflict above)
-        SecretCache.invalidate_variable(key)
+        with create_session() as session:

Review Comment:
   Yep can do this



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