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

In some cases, error message "specified line no longer in file, maybe it changed?" is not because the file changed #16456

Closed
alzeih opened this issue Jun 27, 2016 · 10 comments · Fixed by #73241
Labels
affects_2.1 This issue/PR affects Ansible v2.1 bug This issue/PR relates to a bug. has_pr This issue has an associated PR. P3 Priority 3 - Approved, No Time Limitation support:core This issue/PR relates to code supported by the Ansible Engineering Team.

Comments

@alzeih
Copy link

alzeih commented Jun 27, 2016

ISSUE TYPE
  • Bug Report
COMPONENT NAME

ansible core

ANSIBLE VERSION
ansible 2.1.0.0
  config file = 
  configured module search path = Default w/o overrides
CONFIGURATION

N/A

OS / ENVIRONMENT

N/A

SUMMARY

The error message (specified line no longer in file, maybe it changed?) is caused when there is a syntax error on the last line, and that line also contains variable interpolation. The error message points to the line after the end of the file and prints the above message.

STEPS TO REPRODUCE

Using a playbook site.yml


---
- hosts: localhost
  roles:
  - a

With two roles: a, b

When roles/a/meta/main.yml contains this broken syntax including variable interpolation on the last line of yaml content of the file

dependencies:
  - { role: b, a_value="{{ "foo" }}" }

And the playbook is run with ansible-playbook site.yml

Then it produces an error message which points to a line in the file which doesn't exist:

ERROR! Syntax Error while loading YAML.


The error appears to have been in '[snip]/roles/a/meta/main.yml': line 3, column 1, but may
be elsewhere in the file depending on the exact syntax problem.

(specified line no longer in file, maybe it changed?)
EXPECTED RESULTS

I expected to find the file had changed and this was a temporary error, but it occurs consistently.

I know the syntax is incorrect, however the error message about the file changing is very confusing. I'm able to guess the error is on the previous line, but I don't think the error should reference a line that doesn't exist at all in the file.

I think it makes it difficult to debug and as it occurs in such limited circumstances it's not referenced much, and the phrase isn't easy to search for.

I either expected the error to relate to a line in the given file, or be shown the interpolated output with the line that caused the error.

This seems related to #14549 in general, but opened separately as it may be caused by a different mechanism. It may be caused by external parser library so this might belong further upstream.

@Dapsang
Copy link

Dapsang commented Aug 2, 2016

+1

1 similar comment
@unikideas
Copy link

+1

@ansibot ansibot added triage affects_2.1 This issue/PR affects Ansible v2.1 labels Sep 7, 2016
@bcoca bcoca removed the triage label Dec 16, 2016
@seljuck
Copy link

seljuck commented Mar 16, 2017

+1

@ansibot ansibot added needs_info This issue requires further information. Please answer any outstanding questions. and removed needs_info This issue requires further information. Please answer any outstanding questions. labels Mar 29, 2017
@ChenXiaoTemp
Copy link

+1

@ChenXiaoTemp
Copy link

I found it is my scripts' problem, the quotation in the last line of my script is not matched.

@Justinbobustin
Copy link

+1

@ansibot ansibot added the support:core This issue/PR relates to code supported by the Ansible Engineering Team. label Jun 29, 2017
@orlra
Copy link

orlra commented Feb 28, 2018

Same problem with quotation. Seems bad that error is so bad that whole file is considered broken, and no way to point line except manual inspection.

@ansibot ansibot added bug This issue/PR relates to a bug. and removed bug_report labels Mar 1, 2018
@cjward-cba
Copy link

+1

@ansibot ansibot added support:community This issue/PR relates to code supported by the Ansible community. and removed support:core This issue/PR relates to code supported by the Ansible Engineering Team. labels Sep 22, 2018
@Sylvain303
Copy link

The error message can also be produced with this playbook

---
- hosts: localhost
  tasks:
  - debug:
      msg: "unterminated quoted string                                                                                                                                                        

notice as it is colorized, you may miss the missing quote.

ansible --version
ansible 2.8.3
  config file = /root/ansible/ansible.cfg
  configured module search path = [u'/root/.ansible/plugins/modules', u'/usr/share/ansible/plugins/modules']
  ansible python module location = /usr/lib/python2.7/dist-packages/ansible
  executable location = /usr/bin/ansible
  python version = 2.7.13 (default, Sep 26 2018, 18:42:22) [GCC 6.3.0 20170516]

@ansibot ansibot added support:core This issue/PR relates to code supported by the Ansible Engineering Team. and removed support:community This issue/PR relates to code supported by the Ansible community. labels Mar 24, 2020
@bcoca bcoca added the P3 Priority 3 - Approved, No Time Limitation label Jan 8, 2021
@samdoran
Copy link
Contributor

Can anyone test with #73241 to see if that fixes the issue?

@ansibot ansibot added the has_pr This issue has an associated PR. label Jan 14, 2021
@ansible ansible locked and limited conversation to collaborators Feb 16, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
affects_2.1 This issue/PR affects Ansible v2.1 bug This issue/PR relates to a bug. has_pr This issue has an associated PR. P3 Priority 3 - Approved, No Time Limitation 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.