Skip to content

Commit

Permalink
Fix AttributeError when running ec2_metadata_facts (ansible-collectio…
Browse files Browse the repository at this point in the history
…ns#1138)

Fix AttributeError when running ec2_metadata_facts

SUMMARY
Prior to 5.0.0 we caught "Exception" within fetch, this was limited to json.JSONDecodeError, however it looks like we also needed to catch AttributeError for non-dict JSON
ISSUE TYPE

Bugfix Pull Request

COMPONENT NAME
ec2_metadata_facts
ADDITIONAL INFORMATION
fixes: ansible-collections#1134
  • Loading branch information
tremble authored Oct 8, 2022
1 parent 6d0d5ad commit c269898
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
bugfixes:
- ec2_metadata_facts - fixed ``AttributeError`` (https://github.com/ansible-collections/amazon.aws/issues/1134).
2 changes: 1 addition & 1 deletion plugins/modules/ec2_metadata_facts.py
Original file line number Diff line number Diff line change
Expand Up @@ -528,7 +528,7 @@ def fetch(self, uri, recurse=True):
self._data['%s' % (new_uri)] = content
for (key, value) in json_dict.items():
self._data['%s:%s' % (new_uri, key.lower())] = value
except json.JSONDecodeError:
except (json.JSONDecodeError, AttributeError):
self._data['%s' % (new_uri)] = content # not a stringified JSON string

def fix_invalid_varnames(self, data):
Expand Down

0 comments on commit c269898

Please sign in to comment.