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

The quote filter fails on integers #33260

Closed
wknapik opened this issue Nov 24, 2017 · 3 comments · Fixed by #33272
Closed

The quote filter fails on integers #33260

wknapik opened this issue Nov 24, 2017 · 3 comments · Fixed by #33272
Labels
affects_2.5 This issue/PR affects Ansible v2.5 bug This issue/PR relates to a bug. module This issue/PR relates to a module. support:core This issue/PR relates to code supported by the Ansible Engineering Team.

Comments

@wknapik
Copy link
Contributor

wknapik commented Nov 24, 2017

ISSUE TYPE

Bug Report

COMPONENT NAME

shell

ANSIBLE VERSION
ansible 2.5.0
  config file = /etc/ansible/ansible.cfg
  configured module search path = [u'/home/foo/.ansible/plugins/modules', u'/usr/share/ansible/plugins/modules']
  ansible python module location = /usr/lib/python2.7/site-packages/ansible
  executable location = /usr/bin/ansible
  python version = 2.7.14 (default, Sep 20 2017, 01:25:59) [GCC 7.2.0]

2.5.0.34173.3d63ecb6f3-1

CONFIGURATION

DEFAULT_STDOUT_CALLBACK(/etc/ansible/ansible.cfg) = debug

OS / ENVIRONMENT

N/A

SUMMARY

I was expecting the quote filter to work with integers, without an explicit cast. It does not.

STEPS TO REPRODUCE
ansible -m shell -a 'echo {{ 42|quote }}' localhost
EXPECTED RESULTS

Success.

ACTUAL RESULTS

Failure.

Unexpected templating type error occurred on (echo {{ 42|quote }}): 'int' object is not iterable
@ansibot
Copy link
Contributor

ansibot commented Nov 24, 2017

Files identified in the description:

If these files are inaccurate, 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.5 This issue/PR affects Ansible v2.5 bug_report module This issue/PR relates to a module. needs_triage Needs a first human triage before being processed. support:core This issue/PR relates to code supported by the Ansible Engineering Team. labels Nov 24, 2017
@wknapik
Copy link
Contributor Author

wknapik commented Nov 24, 2017

If this is considered intended behavior, then at least the error message should be improved. When this failed for me the first time, it was in a task with 14 quoted variables. Took a while to figure out where exactly the problem was.

bcoca added a commit to bcoca/ansible that referenced this issue Nov 24, 2017
@alikins
Copy link
Contributor

alikins commented Nov 27, 2017

That is a pretty terrible error message. But not sure it can be improved much. The hidden traceback:

Traceback (most recent call last):
  File "/home/adrian/src/ansible/lib/ansible/template/__init__.py", line 676, in do_template
    res = j2_concat(rf)
  File "<template>", line 12, in root
  File "/home/adrian/src/ansible/lib/ansible/plugins/filter/core.py", line 144, in quote
    return shlex_quote(a)
  File "/usr/lib64/python2.7/pipes.py", line 269, in quote
    for c in file:
TypeError: 'int' object is not iterable

The change in #33272 to always convert to text seems reasonable for this case and should avoid that error as well.

@alikins alikins removed the needs_triage Needs a first human triage before being processed. label Nov 27, 2017
abadger pushed a commit that referenced this issue Dec 6, 2017
fixes #33260

(cherry picked from commit 65ffb92)
abadger pushed a commit that referenced this issue Dec 6, 2017
@ansibot ansibot added bug This issue/PR relates to a bug. and removed bug_report labels Mar 7, 2018
@ansible ansible locked and limited conversation to collaborators Apr 26, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
affects_2.5 This issue/PR affects Ansible v2.5 bug This issue/PR relates to a bug. module This issue/PR relates to a module. support:core This issue/PR relates to code supported by the Ansible Engineering Team.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants