-
Notifications
You must be signed in to change notification settings - Fork 23.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Double extended error message in AnsibleParserError (triple in 2.4) #36848
Comments
Files identified in the description: If these files are inaccurate, please update the |
!component +lib/ansible/errors/init.py |
Files identified in the description: If these files are inaccurate, please update the |
Files identified in the description: If these files are inaccurate, please update the |
The mod_args.py and task.py cases need some tweaking, since currently they catch AnsibleParserError and then raises a new AnsibleParserError() with additional args, so the final displayed exception's orig_exc has two or more instances of the same exception type with the same message. And when displayed as shown, that doesn't make a ton of sense. |
For cases like: https://github.com/ansible/ansible/blob/devel/lib/ansible/playbook/task.py#L187 ... guess there is no particular reason to re raise a new AnsibleParserError in those cases. try:
whatever()
except AnsibleParserError as e:
# if we don't need to add/change the AnsibleError._obj, just re raise
raise
try:
whatever(some_thing_related_to_some_yaml_object)
except AnsibleParserError as e:
# if whatever() doesn't specify obj=some_yaml_obj when it raises AnsibleParserError()
# we can just set/update it here and re raise
e._obj = some_yaml_obj
raise |
* Fix redundant yaml error blurbs on ModArgs parse errors Some of the AnsibleParserErrors from parsing.mod_args are created with the obj=some_yaml_ds options but some are not. If they were, we don't want to add another yaml_ds to it, because that will result in double yaml error blurbs. And since we dont need to add info, we can just re raise it. But if there is no ._obj, add it here so we get the extra detail in the error message (see issue #14790) and raise a new AnsibleParserError instance. Fixes #36848 * cleanup existing test_tasks pep8/sanity issues
* Fix redundant yaml error blurbs on ModArgs parse errors Some of the AnsibleParserErrors from parsing.mod_args are created with the obj=some_yaml_ds options but some are not. If they were, we don't want to add another yaml_ds to it, because that will result in double yaml error blurbs. And since we dont need to add info, we can just re raise it. But if there is no ._obj, add it here so we get the extra detail in the error message (see issue #14790) and raise a new AnsibleParserError instance. Fixes #36848 * cleanup existing test_tasks pep8/sanity issues (cherry picked from commit e166946)
ISSUE TYPE
COMPONENT NAME
AnsibleError, AnsibleParserError, Task#preprocess_data, ModuleArgsParser#parse
ANSIBLE VERSION
CONFIGURATION
No special configuration, local connection.
ansible-playbook -c local -i localhost, playbook.yml
playbook.yml:
OS / ENVIRONMENT
Ubuntu 16.04, Python 3.5.2 (default, Nov 23 2017, 16:37:01) in virtualenv
SUMMARY
ModuleArgsParser#parse
raisesAnsibleParserError
if something is wrong with tasks or their arguments.AnsibleParserError#__init__
append extended error to the message.Then
Task#preprocess_data
wrapsAnsibleParserError
with new instance ofAnsibleParserError
and thus extended error is doubled in message.Extended error is printed 3 times in version 2.4.
devel
branch has merged PR #24468 and extended error is printed 2 times.May be something wrong with this wrapping?
ansible/lib/ansible/playbook/task.py
Lines 183 to 187 in ebf971f
STEPS TO REPRODUCE
Simple test case that raises error about extra params from
ansible/lib/ansible/parsing/mod_args.py
Line 303 in ebf971f
Create file and run it localy for verification:
EXPECTED RESULTS
Clean error message with offending lines:
ACTUAL RESULTS
devel branch:
Double output
version 2.4 (git checkout stable-2.4)
Triple output
The text was updated successfully, but these errors were encountered: