Skip to content

Commit

Permalink
Fix AttributeError when running ec2_metadata_facts (#1138) (#1141)
Browse files Browse the repository at this point in the history
[PR #1138/c269898a backport][stable-5] Fix AttributeError when running ec2_metadata_facts

This is a backport of PR #1138 as merged into main (c269898).
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: #1134

Reviewed-by: Mark Chappell <None>
  • Loading branch information
patchback[bot] authored Oct 10, 2022
1 parent 5b39507 commit 6a3acb1
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 6a3acb1

Please sign in to comment.