Fix NameError, value was not available in this context leading to a generic unexpected error. Fixes #33275 (#41856)

This commit is contained in:
Matt Martz 2018-06-25 15:04:32 -05:00 committed by GitHub
parent 24e94ec3c6
commit d255cf42d7
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -427,6 +427,7 @@ class FieldAttributeBase(with_metaclass(BaseMeta, object)):
# and assign the massaged value back to the attribute field # and assign the massaged value back to the attribute field
setattr(self, name, value) setattr(self, name, value)
except (TypeError, ValueError) as e: except (TypeError, ValueError) as e:
value = getattr(self, name)
raise AnsibleParserError("the field '%s' has an invalid value (%s), and could not be converted to an %s." raise AnsibleParserError("the field '%s' has an invalid value (%s), and could not be converted to an %s."
"The error was: %s" % (name, value, attribute.isa, e), obj=self.get_ds(), orig_exc=e) "The error was: %s" % (name, value, attribute.isa, e), obj=self.get_ds(), orig_exc=e)
except (AnsibleUndefinedVariable, UndefinedError) as e: except (AnsibleUndefinedVariable, UndefinedError) as e: