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

More useful var templating errors #80333

Open
1 task done
Vladimir-csp opened this issue Mar 28, 2023 · 2 comments
Open
1 task done

More useful var templating errors #80333

Vladimir-csp opened this issue Mar 28, 2023 · 2 comments
Labels
affects_2.15 data_tagging feature This issue/PR relates to a feature request. module This issue/PR relates to a module.

Comments

@Vladimir-csp
Copy link

Vladimir-csp commented Mar 28, 2023

Summary

When a templated var fails due to error in template, the error message is unhelpful and hard to read. It consists of:

  • A message An unhandled exception occured while templating
  • Literal representation of template
  • The actual error message, i.e. Error was a class 'ansible.errors.AnsibleError'>, original message: template error while templating string: expected an expression, got 'end of statement block. String:
  • Another literal representation of template.

No indication where in the template (row, column) the error has occured. Also it is hard hard to find the actual template error between two redundant printings of the same template.

The feature request is: show the actual template error text, then info on location of the error, and only then a single printing of the template, maybe with the error position marked as it is with yaml errors.

Issue Type

Feature Idea

Component Name

template

Additional Information

Current error message:

fatal: [hostname]: FAILED! => 
  msg: |-
    An unhandled exception occurred while templating '{# lots #}
    {# and lots #}
    {# and lots #)
    {# and lots #}
    {# and lots of template text #}'. Error was a <class 'ansible.errors.AnsibleError'>, original message: template error while templating string: Unexpected ')', expected '}'. String: {# lots #}
    {# and lots #}
    {# and lots #)
    {# and lots #}
    {# and lots of template text #}

Suggested:

fatal: [hostname]: FAILED! => 
  msg: |-
    template error while templating string: Unexpected ')', expected '}'. Line 3, Col 14, String: 
    {# lots #}
    {# and lots #}
    {# and lots #)
                 ^ here
    {# and lots #}
    {# and lots of template text #}

Code of Conduct

  • I agree to follow the Ansible Code of Conduct
@ansibot
Copy link
Contributor

ansibot commented Mar 28, 2023

Files identified in the description:
None

If these files are incorrect, please update the component name section of the description or use the !component bot command.

click here for bot help

@ansibot ansibot added affects_2.15 feature This issue/PR relates to a feature request. needs_triage Needs a first human triage before being processed. labels Mar 28, 2023
@mkrizek mkrizek removed the needs_triage Needs a first human triage before being processed. label Mar 28, 2023
@ansibot
Copy link
Contributor

ansibot commented Jul 11, 2023

Files identified in the description:

If these files are incorrect, please update the component name section of the description or use the !component bot command.

click here for bot help

@ansibot ansibot added the module This issue/PR relates to a module. label Jul 11, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
affects_2.15 data_tagging feature This issue/PR relates to a feature request. module This issue/PR relates to a module.
Projects
None yet
Development

No branches or pull requests

4 participants