vscode-yaml icon indicating copy to clipboard operation
vscode-yaml copied to clipboard

"unidentified alias" not expected

Open wlmitch opened this issue 4 years ago • 7 comments

Describe the bug

When using an anchor like this:

foo:
  - &name bar
*name:
  - baz

Expected Behavior

Syntax is valid, so I expect no error

Ouput via yamllint

--- 
bar: 
  - baz
foo: 
  - bar

Current Behavior

image

Environment

  • [x] Windows
  • [ ] Mac
  • [ ] Linux
  • [ ] other (please specify)

wlmitch avatar Apr 15 '21 15:04 wlmitch

@eemeli This looks like one case where the parser is acting differently. Can you check it?

gorkem avatar Apr 16 '22 20:04 gorkem

yamllint is wrong here. Unfortunately, : is a valid alias character, which means that it doesn't get included as a mapping indicator here, but as a part of the alias.

The error is a bit surprising, though. At least with the latest yaml@2, that input ought to result in an error

YAMLParseError: Implicit map keys need to be followed by map values at line 3, column 1:

  - &name bar
*name:
^^^^^^

and a warning

YAMLWarning: Alias ending in : is ambiguous at line 3, column 6:

*name:
     ^

eemeli avatar Apr 17 '22 05:04 eemeli

I also see the same 2 errors with the latest release.

gorkem avatar Apr 22 '22 19:04 gorkem

@gorkem When testing this manually myself, I see this: Screenshot 2022-04-23 at 15 44 38

Is there a way for vscode-yaml to also show the warnings produced by yaml?

eemeli avatar Apr 23 '22 12:04 eemeli

@eemeli can you check the "Problems" view, if there are more reported?

gorkem avatar Apr 23 '22 16:04 gorkem

Just noticed that I was looking at a build from HEAD which lists 2 problems as expected. When I revert to 1.6.0 it shows only a single item.

gorkem avatar Apr 23 '22 17:04 gorkem

We have a similar use case for the yaml files we use in puppet. While the YAML extension complains about this problem, the Puppet's engine is able to consume the YAML files as intended without any problem.

image

Udemon avatar Feb 13 '24 12:02 Udemon