mirror of
https://github.com/ansible-collections/community.general.git
synced 2026-05-08 06:12:51 +00:00
Handle exception raised in recursive_finder API (#49590)
User module can contain Indentation errors or syntax errors. Handle AST exceptions rather than showing traceback while importing such module. Fixes: #21707 Signed-off-by: Abhijeet Kasurde <akasurde@redhat.com>
This commit is contained in:
@@ -462,7 +462,10 @@ def recursive_finder(name, data, py_module_names, py_module_cache, zf):
|
||||
the module its module_utils files needs.
|
||||
"""
|
||||
# Parse the module and find the imports of ansible.module_utils
|
||||
tree = ast.parse(data)
|
||||
try:
|
||||
tree = ast.parse(data)
|
||||
except (SyntaxError, IndentationError) as e:
|
||||
raise AnsibleError("Unable to import %s due to %s" % (name, e.msg))
|
||||
finder = ModuleDepFinder()
|
||||
finder.visit(tree)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user