Skip to content

Conversation

bcoca
Copy link
Member

@bcoca bcoca commented Oct 26, 2022

previously it would have a 2nd tb due to bad error raising

ISSUE TYPE
  • Bugfix Pull Request
COMPONENT NAME

lookup/file

ADDITIONAL INFORMATION

what to run:

$ ansible -m debug -a 'msg="{{q("file", "/etc/nothere")}}"' localhost -vvv

before PR

[WARNING]: Unable to find '/etc/nothere' in expected paths (use -vvvvv to see paths)
exception during Jinja2 execution: Traceback (most recent call last):
  File "ansible/lib/ansible/plugins/lookup/file.py", line 84, in run
    raise AnsibleParserError()
ansible.errors.AnsibleParserError

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "ansible/lib/ansible/template/__init__.py", line 831, in _lookup
    ran = instance.run(loop_terms, variables=self._available_variables, **kwargs)
  File "ansible/lib/ansible/plugins/lookup/file.py", line 86, in run
    raise AnsibleError("could not locate file in lookup: %s" % term)
ansible.errors.AnsibleError: could not locate file in lookup: /etc/nothere
localhost | FAILED! => {
    "msg": "An unhandled exception occurred while running the lookup plugin 'file'. Error was a <class 'ansible.errors.AnsibleError'>, original message: could not locate file in lookup: /etc/nothere. could not locate file in lookup: /etc/nothere"
}

after:

localhost | FAILED! => {
    "msg": "The 'file' lookup had an issue accessing the file '/etc/nothere'. file not found, use -vvvvv to see paths searched"
}

@ansibot ansibot added affects_2.15 bug This issue/PR relates to a bug. needs_triage Needs a first human triage before being processed. traceback This issue/PR includes a traceback. labels Oct 26, 2022
@mattclay mattclay removed the needs_triage Needs a first human triage before being processed. label Oct 27, 2022
@bcoca bcoca merged commit aaab079 into ansible:devel Oct 27, 2022
@bcoca bcoca deleted the file_lookup_fix branch October 27, 2022 19:28
bcoca added a commit to bcoca/ansible that referenced this pull request Oct 27, 2022
 previously it would have a 2nd tb due to bad error raising
 also remove superfluous warning

(cherry picked from commit aaab079)
bcoca added a commit to bcoca/ansible that referenced this pull request Oct 27, 2022
 previously it would have a 2nd tb due to bad error raising
 also remove superfluous warning

(cherry picked from commit aaab079)
nitzmahone pushed a commit that referenced this pull request Oct 28, 2022
previously it would have a 2nd tb due to bad error raising
 also remove superfluous warning

(cherry picked from commit aaab079)
@ansible ansible locked and limited conversation to collaborators Nov 3, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
affects_2.15 bug This issue/PR relates to a bug. traceback This issue/PR includes a traceback.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants