Skip to content

crasher: AttributeError: 'CommentedSeq' object has no attribute 'get' - v2 #4492

Closed
@sdarwin

Description

An issue had been closed due to not including reproducing data.

"crasher: AttributeError: 'CommentedSeq' object has no attribute 'get'"

#3612

"It is a crash that still exists and is easily reproduced."

"And it looks like at least 7 people have reported running into it. I agree, a crasher with a clear and simple reproduction is worth re-opening."

The problem is caused by a superfluous "---".

This happened to me as well. After I removed the --- in the middle, the error was gone.

ansible-lint should detect and report a linting issue instead of crashing:

  File "/root/venv/lib/python3.12/site-packages/ansiblelint/skip_utils.py", line 315, in <genexpr>
    return any(task.get(key) for key in NESTED_TASK_KEYS)
               ^^^^^^^^
AttributeError: 'CommentedSeq' object has no attribute 'get'

Edit:

Not sure how Ansible itself (not ansible-lint) treats this situation. Does Ansible support multiple documents in one file? From https://gettaurus.org/docs/YAMLTutorial

YAML Multi Documents: YAML format allows multiple documents to be embedded in a single file. They only have to be separated with a line containing triple-dash separator ---.

document: this is document 1
---
document: this is document 2

Metadata

Assignees

Labels

Type

No type

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions