mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
Make sure string attributes are strings from YAML to avoid bad type conversions
Fixes #12367
This commit is contained in:
parent
7c669f5a33
commit
cfdaec0c22
1 changed files with 6 additions and 0 deletions
|
@ -231,6 +231,12 @@ class Base:
|
|||
method = getattr(self, '_validate_%s' % name, None)
|
||||
if method:
|
||||
method(attribute, name, getattr(self, name))
|
||||
else:
|
||||
# and make sure the attribute is of the type it should be
|
||||
value = getattr(self, name)
|
||||
if value is not None:
|
||||
if attribute.isa == 'string' and not isinstance(value, string_types):
|
||||
raise AnsibleParserError("The field '%s' is supposed to be a string type, however the incoming data structure is a %s" % (name, type(value)), obj=self.get_ds())
|
||||
|
||||
def copy(self):
|
||||
'''
|
||||
|
|
Loading…
Reference in a new issue