redhat-developer / redhat-developer/vscode-yaml
"Incorrect type" for Serverless Application Model condition if filename ends in `.sam.yaml`
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 829
- Forks
- 260
- Avg merge
- 5h 43m
- Merged PRs (30d)
- 1
Description
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)
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Reproduce the issue in VS Code using the supplied SAM YAML content, comparing foo.yaml with foo.sam.yaml and sam.yaml while keeping the yaml.customTags settings. Trace how the filename selects the AWS SAM schema, then verify that the !Equals condition is no longer reported as an incorrect type for the affected filenames.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript, yaml
- Domain
- tooling
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100