redhat-developer / vscode-yaml

YAML support for VS Code with built-in kubernetes syntax support
MIT License
664 stars 222 forks source link

YAML Anchors and References Break Schema Validation and Suggestions #425

Open svrx opened 3 years ago

svrx commented 3 years ago

Describe the bug

When user anchors or references in CloudFormation YAML files, schemas stops working when anchors/references are used.

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

  1. Add an anchor to any element
    ...
    Tags: &tags
    - Key: Application
     Value: MyApp
    ...

    Environment

    • [x] Windows
    • [ ] Mac
    • [ ] Linux
    • [ ] other (please specify)
evidolob commented 3 years ago

@svrx Can you share more info on this? I cannot reproduce this:

Screenshot 2021-02-24 at 14 53 38

Do you use only vscode-yaml ? Or some other extension which depends on it?

svrx commented 3 years ago

Thanks for investigating. I've investigated the issue further on my setup and have been able to narrow down to some interaction with kddejong.vscode-cfn-lint.

Will bring to maintainers awareness.

Is there anything you can check on your side? Otherwise feel free to close this issue for now.

evidolob commented 3 years ago

It would be nice, if you can share yaml, on which you got validation broken, to let me check more deeply.

svrx commented 3 years ago

Something as simple as this is enough.

AWSTemplateFormatVersion: '2010-09-09' 
Resources:
  ServiceCluster:
    Type: AWS::ECS::Cluster
    Properties:
      ClusterName: ClusterName
      Tags: &tags
        - Key: Application
          Value: AppName
        - Key: ApplicationRole
          Value: FrontEnd
  WebLoadBalancer:
    Type: AWS::ElasticLoadBalancingV2::LoadBalancer
    Properties:
      Name: LBName
      Type: application
      Tags: *tags

As soon as the anchor (&tags) is added, following error start appearing anytime an element is hovered. image

evidolob commented 3 years ago

It is bug kddejong.vscode-cfn-lint in as they use node-yaml-parser to parse yaml and it seems it not support yaml anchor's. I will investigate more next week, we need to improve our behavior in case if contributing extension fails.

svrx commented 3 years ago

Thanks. Already opened issue with then about the issue. https://github.com/aws-cloudformation/aws-cfn-lint-visual-studio-code/issues/158