mirror of
https://github.com/ansible-collections/community.general.git
synced 2026-05-06 13:22:48 +00:00
better handling of bad type in config (#48821)
* better handling of bad type in config fixes #22468, fixes #22476
This commit is contained in:
@@ -436,7 +436,15 @@ class ConfigManager(object):
|
||||
return value, origin
|
||||
|
||||
# ensure correct type, can raise exceptoins on mismatched types
|
||||
value = ensure_type(value, defs[config].get('type'), origin=origin)
|
||||
try:
|
||||
value = ensure_type(value, defs[config].get('type'), origin=origin)
|
||||
except ValueError as e:
|
||||
if origin.startswith('env:') and value == '':
|
||||
# this is empty env var for non string so we can set to default
|
||||
origin = 'default'
|
||||
value = ensure_type(defs[config].get('default'), defs[config].get('type'), origin=origin)
|
||||
else:
|
||||
raise AnsibleOptionsError('Invalid type for configuration option %s: %s' % (to_native(config), to_native(e)))
|
||||
|
||||
# deal with deprecation of the setting
|
||||
if 'deprecated' in defs[config] and origin != 'default':
|
||||
|
||||
Reference in New Issue
Block a user