mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-04-26 04:11:25 -07: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:
parent
73ffe683b2
commit
bc6cd13874
2 changed files with 18 additions and 1 deletions
|
@ -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)
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue