Closed pb82 closed 10 months ago
The issue is seeing while scanning the repository using Ansible Code Bot.
The error (it may not be the only one, though) occurs with https://github.com/ansible-collections/amazon.aws/blob/main/tests/integration/targets/elb_classic_lb/tasks/schema_change.yml
$ ansible-lint --fix=all tests/integration/targets/elb_classic_lb/tasks/schema_change.yml
WARNING Skipped installing collection dependencies due to running in offline mode.
Traceback (most recent call last):
File "/var/tmp/work3/venv/bin/ansible-lint", line 8, in <module>
sys.exit(_run_cli_entrypoint())
File "/var/tmp/work3/venv/lib64/python3.9/site-packages/ansiblelint/__main__.py", line 402, in _run_cli_entrypoint
sys.exit(main(sys.argv))
File "/var/tmp/work3/venv/lib64/python3.9/site-packages/ansiblelint/__main__.py", line 379, in main
fix(runtime_options=options, result=result, rules=rules)
File "/var/tmp/work3/venv/lib64/python3.9/site-packages/ansiblelint/__main__.py", line 248, in fix
_do_transform(result, options)
File "/var/tmp/work3/venv/lib64/python3.9/site-packages/ansiblelint/__main__.py", line 203, in _do_transform
transformer.run()
File "/var/tmp/work3/venv/lib64/python3.9/site-packages/ansiblelint/transformer.py", line 118, in run
self._do_transforms(file, ruamel_data or data, file_is_yaml, matches)
File "/var/tmp/work3/venv/lib64/python3.9/site-packages/ansiblelint/transformer.py", line 156, in _do_transforms
match.rule.transform(match, file, data)
File "/var/tmp/work3/venv/lib64/python3.9/site-packages/ansiblelint/rules/name.py", line 179, in transform
] = f"{target_task['name'][:1].upper()}{target_task['name'][1:]}"
File "/var/tmp/work3/venv/lib64/python3.9/site-packages/ruamel/yaml/comments.py", line 851, in __getitem__
return ordereddict.__getitem__(self, key)
KeyError: 'name'
A KeyError occurs with https://github.com/ansible-collections/amazon.aws/blob/main/tests/integration/targets/s3_object/tasks/main.yml as well:
$ ansible-lint --fix=all tests/integration/targets/s3_object/tasks/main.yml
WARNING Skipped installing collection dependencies due to running in offline mode.
Traceback (most recent call last):
File "/home/ttakamiy/git/ansible-collections/amazon.aws/venv/bin/ansible-lint", line 8, in <module>
sys.exit(_run_cli_entrypoint())
File "/home/ttakamiy/git/ansible-collections/amazon.aws/venv/lib64/python3.9/site-packages/ansiblelint/__main__.py", line 402, in _run_cli_entrypoint
sys.exit(main(sys.argv))
File "/home/ttakamiy/git/ansible-collections/amazon.aws/venv/lib64/python3.9/site-packages/ansiblelint/__main__.py", line 379, in main
fix(runtime_options=options, result=result, rules=rules)
File "/home/ttakamiy/git/ansible-collections/amazon.aws/venv/lib64/python3.9/site-packages/ansiblelint/__main__.py", line 248, in fix
_do_transform(result, options)
File "/home/ttakamiy/git/ansible-collections/amazon.aws/venv/lib64/python3.9/site-packages/ansiblelint/__main__.py", line 203, in _do_transform
transformer.run()
File "/home/ttakamiy/git/ansible-collections/amazon.aws/venv/lib64/python3.9/site-packages/ansiblelint/transformer.py", line 119, in run
self._do_transforms(file, ruamel_data or data, file_is_yaml, matches)
File "/home/ttakamiy/git/ansible-collections/amazon.aws/venv/lib64/python3.9/site-packages/ansiblelint/transformer.py", line 157, in _do_transforms
match.rule.transform(match, file, data)
File "/home/ttakamiy/git/ansible-collections/amazon.aws/venv/lib64/python3.9/site-packages/ansiblelint/rules/name.py", line 179, in transform
] = f"{target_task['name'][:1].upper()}{target_task['name'][1:]}"
File "/home/ttakamiy/git/ansible-collections/amazon.aws/venv/lib64/python3.9/site-packages/ruamel/yaml/comments.py", line 851, in __getitem__
return ordereddict.__getitem__(self, key)
KeyError: 'name'
Summary
When running
ansible-lint --fix
against https://github.com/ansible-collections/amazon.aws.git, aKeyError
is raised and ansible-lint fails:Issue Type
OS / ENVIRONMENT
STEPS TO REPRODUCE
ansible-lint --fix
in that repository directoryDesired Behavior
ansible-lint should not fail with a KeyError and exit code 1.
Actual Behavior
ansible-lint fails with a KeyError, exit code is 1.
[minimum complete verifiable example]: see above