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

YAML Anchors and References Break Schema Validation and Suggestions

Open svrx opened this issue 4 years ago • 6 comments

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)

svrx avatar Feb 08 '21 13:02 svrx

@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?

evidolob avatar Feb 24 '21 12:02 evidolob

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.

svrx avatar Mar 02 '21 09:03 svrx

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

evidolob avatar Mar 02 '21 09:03 evidolob

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

svrx avatar Mar 04 '21 15:03 svrx

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.

evidolob avatar Mar 04 '21 15:03 evidolob

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

svrx avatar Mar 04 '21 15:03 svrx