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

Avoid key exception during transform #4156

Merged
merged 1 commit into from
May 13, 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
8 changes: 6 additions & 2 deletions src/ansiblelint/rules/key_order.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,12 +129,16 @@ def transform(
if match.tag == f"{self.id}[play]":
play = self.seek(match.yaml_path, data)
for key in match.transform_meta.fixed:
play[key] = play.pop(key)
# other transformation might change the key
if key in play:
play[key] = play.pop(key)
match.fixed = True
if match.tag == f"{self.id}[task]":
task = self.seek(match.yaml_path, data)
for key in match.transform_meta.fixed:
task[key] = task.pop(key)
# other transformation might change the key
if key in task:
task[key] = task.pop(key)
match.fixed = True


Expand Down
Loading