Prevent traceback when task depth exceeds python recursion depth (#73999)

This commit is contained in:
Matt Martz 2021-04-15 15:52:08 -05:00 committed by GitHub
parent 1082e2ab79
commit cf4a9fcd0f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 8 additions and 1 deletions

View file

@ -0,0 +1,3 @@
bugfixes:
- Task depth - Prevent exception when the task depth exceeds Pythons recursion depth
(https://github.com/ansible/ansible/issues/73996)

View file

@ -15,6 +15,7 @@ from jinja2.exceptions import UndefinedError
from ansible import constants as C
from ansible import context
from ansible.errors import AnsibleError
from ansible.module_utils.six import iteritems, string_types, with_metaclass
from ansible.module_utils.parsing.convert_bool import boolean
from ansible.errors import AnsibleParserError, AnsibleUndefinedVariable, AnsibleAssertionError
@ -315,7 +316,10 @@ class FieldAttributeBase(with_metaclass(BaseMeta, object)):
Create a copy of this object and return it.
'''
new_me = self.__class__()
try:
new_me = self.__class__()
except RuntimeError as e:
raise AnsibleError("Exceeded maximum object depth. This may have been caused by excessive role recursion", orig_exc=e)
for name in self._valid_attrs.keys():
if name in self._alias_attrs: