mirror of
https://github.com/ansible-collections/community.general.git
synced 2026-05-07 22:02:50 +00:00
Properly wrap objects using json default encoder
Our custom encoder for the to_json filter was simply returning the object if it was not a HostVars object, leading in some cases to a TypeError when the data contained an undefined variable. This lead to an odd error message being propagated up, so we now properly catch this as an undefined variable error. Fixes #15610
This commit is contained in:
@@ -68,7 +68,7 @@ class AnsibleJSONEncoder(json.JSONEncoder):
|
||||
if isinstance(o, HostVars):
|
||||
return dict(o)
|
||||
else:
|
||||
return o
|
||||
return json.JSONEncoder.default(o)
|
||||
|
||||
def to_yaml(a, *args, **kw):
|
||||
'''Make verbose, human readable yaml'''
|
||||
|
||||
Reference in New Issue
Block a user