YAML Anchors and References Break Schema Validation and Suggestions
See original GitHub issueDescribe the bug
When user anchors or references in CloudFormation YAML files, schemas stops working when anchors/references are used.
Originally chased with redhat.vscode-yaml
in https://github.com/redhat-developer/vscode-yaml/issues/425, but became clear the issue was being caused by this extension.
Since CloudFormation supports anchors and references through the aws cloudformation package
path, would it make sense to fix the underlying issue?
Expected Behavior
It works as normal.
Current Behavior
Following error keeps repeating as elements are hovered.
Error thrown while requesting schema "Error: end of the stream or a document separator is expected" when calling the registered contributor "cloudformation"
Steps to Reproduce
- Add an anchor to any element
...
Tags: &tags
- Key: Application
Value: MyApp
...
Environment
- Windows
- Mac
- Linux
- other (please specify)
Issue Analytics
- State:
- Created 3 years ago
- Reactions:1
- Comments:6 (3 by maintainers)
Top Results From Across the Web
YAML Anchors and References Break Schema Validation and ...
Describe the bug When user anchors or references in CloudFormation YAML files, schemas stops working when anchors/references are used.
Read more >Advanced YAML syntax cheatsheet - Educative.io
Here's what we'll cover today: Validator and Parser; Anchors and Alias; Schemas; Escape Sequences; Separators and Directives; Wrapping up ...
Read more >YAML Ain't Markup Language (YAML™) revision 1.2.2
Since in a YAML representation, mapping keys are unordered and nodes may be referenced more than once (have more than one incoming “arrow”),...
Read more >Optimize GitLab CI/CD configuration files
You can't use YAML anchors across multiple files when using the include keyword. Anchors are only valid in the file they were defined...
Read more >YAML Anchor, Aliases and Merge Keys
Schema -validation of a YAML document is only possible when all references and merge keys are represented. However, it is not that every...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
I was able to replicate the only issue I have is that CloudFormation yaml doesn’t support aliasing.
It seems like the main issue impacting me is that Cloudformation Linter causes vscode-yaml validation to be turned off. I’m not sure that the error indicated by the error messages mentioned in the ticket is the cause of my problem.
=== More information ===
@PatMyron You can find the file attached. However, after looking at that PR, I checked the output and found that it detects that it isn’t a Cloudformation file.
I realised that the “yaml.validate” setting is being set to false when the Cloudformation linter is enabled. If I switch it back to true the validation works, despite vscode-yaml still outputting error messages. But it toggles to false again on reload when I have the cfn linter extension enabled. Knowing this makes it much more convenient for me.
Happy to provide any information that can help debug, if you think something still needs to be changed in this extension. Below is a screenshot with the cfn linter output, a screen recording to show what I’m experiencing, and my bitbucket pipeline file.
https://user-images.githubusercontent.com/14281373/141318766-9d6dea31-b53f-467d-8bae-4b42dab46f43.mp4
Bitbucket pipeline file