amoghrajesh commented on code in PR #49107:
URL: https://github.com/apache/airflow/pull/49107#discussion_r2039156924
##########
airflow-core/src/airflow/models/variable.py:
##########
@@ -180,13 +180,11 @@ def get(
return var_val
@staticmethod
- @provide_session
def set(
key: str,
value: Any,
description: str | None = None,
serialize_json: bool = False,
- session: Session = None,
Review Comment:
Handled this in latest commit
##########
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:
+ 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)
@staticmethod
@provide_session
Review Comment:
Handled in latest commit
--
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]