Skip to content
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

Fix redundant yaml error blurbs on ModArgs parse errors #36923

Merged
merged 2 commits into from Mar 19, 2018
Merged

Fix redundant yaml error blurbs on ModArgs parse errors #36923

merged 2 commits into from Mar 19, 2018

Conversation

alikins
Copy link
Contributor

@alikins alikins commented Mar 1, 2018

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

SUMMARY
ISSUE TYPE
  • Bugfix Pull Request
COMPONENT NAME

lib/ansible/playbook/task.py

ANSIBLE VERSION
ansible 2.6.0 (fix_double_parser_error_task_36848 5d6631564e) last updated 2018/03/01 15:36:11 (GMT -400)
  config file = /home/adrian/src/ansible/ansible.cfg
  configured module search path = [u'/home/adrian/ansible/my-modules']
  ansible python module location = /home/adrian/src/ansible/lib/ansible
  executable location = /home/adrian/src/ansible/bin/ansible
  python version = 2.7.14 (default, Feb 17 2018, 10:42:17) [GCC 7.3.1 20180130 (Red Hat 7.3.1-2)]

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
@ansibot ansibot added bug This issue/PR relates to a bug. needs_triage Needs a first human triage before being processed. support:core This issue/PR relates to code supported by the Ansible Engineering Team. test This PR relates to tests. labels Mar 1, 2018
@ansibot
Copy link
Contributor

ansibot commented Mar 1, 2018

The test ansible-test sanity --test pep8 [explain] failed with 1 error:

test/units/playbook/test_task.py:99:5: E303 too many blank lines (2)

click here for bot help

@ansibot ansibot added the needs_revision This PR fails CI tests or a maintainer has requested a review/revision of the PR. label Mar 1, 2018
@ansibot ansibot removed the needs_revision This PR fails CI tests or a maintainer has requested a review/revision of the PR. label Mar 1, 2018
@mkrizek mkrizek removed the needs_triage Needs a first human triage before being processed. label Mar 2, 2018
@ansibot ansibot added the stale_ci This PR has been tested by CI more than one week ago. Close and re-open this PR to get it retested. label Mar 10, 2018
# so we dont need to add it so we can just re raise.
if e._obj:
raise
# But if it wasn't, we can add the yaml object now to get more detail
raise AnsibleParserError(to_native(e), obj=ds, orig_exc=e)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a difference between obj and _obj ?

@abadger
Copy link
Contributor

abadger commented Mar 19, 2018

I like what you're doing here. If my question has an answer that you've already considered, then +1 to merge from me.

@bcoca bcoca merged commit e166946 into ansible:devel Mar 19, 2018
@bcoca bcoca added this to To Do in 2.5.x blocker list via automation Mar 19, 2018
@nitzmahone
Copy link
Member

cherry-picked to stable-2.5 for 2.5.1

nitzmahone pushed a commit that referenced this pull request Mar 29, 2018
* 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)
@nitzmahone nitzmahone moved this from To Do to Done in 2.5.x blocker list Mar 29, 2018
@ansible ansible locked and limited conversation to collaborators Apr 27, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug This issue/PR relates to a bug. stale_ci This PR has been tested by CI more than one week ago. Close and re-open this PR to get it retested. support:core This issue/PR relates to code supported by the Ansible Engineering Team. test This PR relates to tests.
Projects
No open projects
Development

Successfully merging this pull request may close these issues.

Double extended error message in AnsibleParserError (triple in 2.4)
6 participants