Skip to content

"Incorrect type" for Serverless Application Model condition if filename ends in .sam.yaml #1144

@garretwilson

Description

@garretwilson

Describe the bug

The extension is showing an incorrect YAML error, but whether the error is shown depends on the filename of the file being editing—specifically whether the filename is sam.yaml or ends in .sam.yaml.

I'm editing an AWS CloudFormation Serverless Application Model (SAM) YAML file. I have appropriate settings in my settings.json, including (among others) the following:

    "yaml.customTags": [
        "!Equals sequence",
        "!Ref scalar"
    ],

Let's say I have a simple SAM YAML file foo.yaml using language extensions:

AWSTemplateFormatVersion: 2010-09-09
Transform:
  - AWS::LanguageExtensions
  - AWS::Serverless-2016-10-31

Description:
  Foo.

Parameters:
  Foo:
    Description: Some parameter.
    Type: String
    AllowedValues: ['false', 'true']
    Default: 'false'

Conditions:
  IsFoo: !Equals [!Ref Foo, 'true']

That condition shows up just fine in the editor, as expected. But if I change the filename to foo.sam.yaml or sam.yaml, the extension shows an error! In particular !Equals [!Ref Foo, 'true'] is underlined in red, with the following error message:

Incorrect type. Expected "object(AWS CloudFormation Serverless Application Model (SAM))".yaml-schema: AWS CloudFormation Serverless Application Model (SAM)

If I rename the file to foo-sam.yaml or foo.yaml or anything-but-dot-sam.yaml, the error goes away.

I don't believe the filename should influence the linting of the YAML contents.

Environment

  • Windows
  • Mac
  • Linux
  • other (please specify)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions