Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix decryption of trigger kwargs when downgrading. #38743

Merged
merged 2 commits into from
Apr 4, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions airflow/utils/db.py
Original file line number Diff line number Diff line change
Expand Up @@ -993,7 +993,7 @@ def decrypt_trigger_kwargs(*, session: Session) -> None:
# this can happen when we downgrade to an old version before the Trigger table was added
return

for trigger in session.query(Trigger):
for trigger in session.scalars(select(Trigger.encrypted_kwargs)):
ephraimbuddy marked this conversation as resolved.
Show resolved Hide resolved
# decrypt the string and convert it to serialized dict
trigger.encrypted_kwargs = json.dumps(BaseSerialization.serialize(trigger.kwargs))
session.commit()
Expand Down Expand Up @@ -1744,12 +1744,12 @@ def downgrade(*, to_revision, from_revision=None, show_sql_only=False, session:
else:
log.info("Applying downgrade migrations.")
command.downgrade(config, revision=to_revision, sql=show_sql_only)
if _revision_greater(
config,
_REVISION_HEADS_MAP["2.9.0"],
to_revision,
):
decrypt_trigger_kwargs(session=session)
if _revision_greater(
config,
_REVISION_HEADS_MAP["2.9.0"],
to_revision,
):
decrypt_trigger_kwargs(session=session)
ephraimbuddy marked this conversation as resolved.
Show resolved Hide resolved


def drop_airflow_models(connection):
Expand Down