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

Expected <document start> but found <scalar> syntax error wrt comment line between scalars #661

Open
jude opened this issue Feb 20, 2024 · 1 comment

Comments

@jude
Copy link

jude commented Feb 20, 2024

I have a test.yml that is

a
#
b

that is returning an 'error syntax error: expected '', but found '' (syntax)' error.:

$ yamllint test.yml 
test.yml
  3:1       error    syntax error: expected '<document start>', but found '<scalar>' (syntax)

It looks like the error is only happenign when a comment line is in the middle of the file:

  • If I remove the line with the '#', than yamllint doesn't return an error.
  • If I change the '#' character to an 'x', then yamllint doesn't return an error.
  • If I replace the '#' character with a blank line, then yamllint doesn't return an error.
  • if I remove either the 'a' or 'b' lines so the comment is the first or last line of the file, yamllint doesn't return an error.
  • If I change the comment line to '# test', then I still get the " expected '', but found '' (syntax)' error."

My .yamllint file is

extends: default
rules:
  document-start: disable

I'm using yamllint 1.33.0 from https://dl.fedoraproject.org/pub/epel/8/Everything/x86_64/Packages/y/yamllint-1.33.0-1.el8.noarch.rpm

My workaround was to change the file as per below, converting the scalars to empty maps.

a:
#
b:
@adrienverge
Copy link
Owner

Hello,

I don't think your example is valid YAML, which explains the error that yamllint outputs.

You can try different YAML parsers on https://play.yaml.io/main/parser. I tried the Python parser (PyYAML) and the JavaScript one (yaml) and both report a syntax error.

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