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

ScannerError when SLS file contains jinja #195

Open
rsutton1 opened this issue Aug 8, 2022 · 1 comment
Open

ScannerError when SLS file contains jinja #195

rsutton1 opened this issue Aug 8, 2022 · 1 comment

Comments

@rsutton1
Copy link

rsutton1 commented Aug 8, 2022

Whenever I use jinja in an SLS file, I get this error. Any ideas?

>>> from salt_lsp.parser import parse
>>> parse("""vim_installed:
...   pkg.installed:
...     - pkgs:
...       - vim""")
Tree(start=Position(line=0, col=0), end=Position(line=3, col=11), includes=None, extend=None, states=[StateNode(start=Position(line=0, col=0), end=Position(line=3, col=11), identifier='vim_installed', states=[StateCallNode(start=Position(line=1, col=2), end=Position(line=3, col=11), name='pkg.installed', parameters=[StateParameterNode(start=Position(line=2, col=4), end=Position(line=3, col=11), name='pkgs', value=[TokenNode(start=Position(line=3, col=6), end=Position(line=3, col=7), token=BlockEntryToken()), TokenNode(start=Position(line=3, col=8), end=Position(line=3, col=11), token=ScalarToken(plain=True, style=None, value='vim'))])], requisites=[])])])
>>> parse("""{%- set pkg = "vim" -%}
... vim_installed:
...   pkg.installed:
...     - pkgs:
...       - {{ pkg }}""")
Traceback (most recent call last):
  File "/home/vagrant/.pyenv/versions/3.8.13/lib/python3.8/site-packages/salt_lsp/parser.py", line 700, in parse
    for token in tokens:
  File "/home/vagrant/.pyenv/versions/3.8.13/lib/python3.8/site-packages/yaml/__init__.py", line 64, in scan
    while loader.check_token():
  File "/home/vagrant/.pyenv/versions/3.8.13/lib/python3.8/site-packages/yaml/scanner.py", line 116, in check_token
    self.fetch_more_tokens()
  File "/home/vagrant/.pyenv/versions/3.8.13/lib/python3.8/site-packages/yaml/scanner.py", line 258, in fetch_more_tokens
    raise ScannerError("while scanning for the next token", None,
yaml.scanner.ScannerError: while scanning for the next token
found character '%' that cannot start any token
  in "<unicode string>", line 1, column 2:
    {%- set pkg = "vim" -%}
     ^

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/vagrant/.pyenv/versions/3.8.13/lib/python3.8/site-packages/salt_lsp/parser.py", line 753, in parse
    return Parser(document).parse()
  File "/home/vagrant/.pyenv/versions/3.8.13/lib/python3.8/site-packages/salt_lsp/parser.py", line 708, in parse
    if node.start and err.context_mark.column < node.start.col:
AttributeError: 'NoneType' object has no attribute 'column'
>>>
@dcermak
Copy link
Owner

dcermak commented Oct 11, 2022 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants