Skip to content

Commit

Permalink
Avoid key exception during transform
Browse files Browse the repository at this point in the history
Related: #4148
  • Loading branch information
ssbarnea committed May 13, 2024
1 parent e8a71e5 commit 21bea9d
Showing 1 changed file with 6 additions and 2 deletions.
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 tansformation 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 tansformation might change the key
if key in task:
task[key] = task.pop(key)
match.fixed = True


Expand Down

0 comments on commit 21bea9d

Please sign in to comment.