question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Disable schema detection for certain files

See original GitHub issue

First of all, great extension. It is really useful to have yaml files validated (and auto-completed).

However, I have a file in my codebase called some.thing-sam.yml and I get red squiggle marks (linting errors) on valid properties. I believe what happens is that this extension treats the file as a AWS CloudFormation Serverless Application Model (SAM) file, which it isn’t.

I have found a similar issue #98 where the schemaStore validation is disabled completely. But this is not what I want. Ideally I could provide a re-mapping of the file extension, as I believe the filename pattern is the culprit. Renaming the file to anything else but *sam.yml works.

Paraphrasing: Naming a yaml file *sam.yml will trick this extension (or the yaml-language-server) into treating the file as an AWS CloudFormation Serverless Application Model. There should be a way to fix this for the user.

I tried to provide a mapping in my VSCode settings myself, but without any luck:

{
    "yaml.schemas": {
        "https://raw.githubusercontent.com/awslabs/goformation/master/schema/sam.schema.json": "foo.bar"
    }
}

Also noteworthy, the catalog.json has this configuration in place:

    [...]
    {

      "name": "AWS CloudFormation Serverless Application Model (SAM)",

      "description": "The AWS Serverless Application Model (AWS SAM, previously known as Project Flourish) extends AWS CloudFormation to provide a simplified way of defining the Amazon API Gateway APIs, AWS Lambda functions, and Amazon DynamoDB tables needed by your serverless application.",

      "fileMatch": [

        "*.sam.json",

        "*.sam.yml",

        "*.sam.yaml",

        "sam.json",

        "sam.yml",

        "sam.yaml"

      ],

      "url": "https://raw.githubusercontent.com/awslabs/goformation/master/schema/sam.schema.json"

    },
    [...]

Judging from the glob patterns my file (some.thing-sam.yml) shouldn’t have been picked up for linting with that schema in the first place, should it?

[EDIT] It seems the user configuration is merged. I can successfully create a file foo.barand change the file type to YAML and the linting errors are the same. Changing the file extension mapping to foo.foo makes the squiggle lines disappear.

Issue Analytics

  • State:open
  • Created 4 years ago
  • Reactions:17
  • Comments:7

github_iconTop GitHub Comments

15reactions
danielmahoncommented, Jul 23, 2021

So I just tried setting the schema to itself and it worked (surprisingly), no more errors… and no need for a blank file.

# yaml-language-server: $schema=./[current file].yaml

build.yaml

# yaml-language-server: $schema=./build.yaml
targets: # before, this would show an error because of incorrect schema validation
  $default:
    builders:
# ... etc
8reactions
geirsagbergcommented, Nov 18, 2020

Same issue here with a file called something.deploy.yml, seems to think my file should match “https://raw.githubusercontent.com/deployphp/deployer/master/src/schema.json”, but it is just a GitHub Actions workflow…

Read more comments on GitHub >

github_iconTop Results From Across the Web

Using schema auto-detection | BigQuery - Google Cloud
Using the Google Cloud console, you can enable schema auto-detection by checking the Schema and input parameters option for Auto detect. Using the...
Read more >
Power BI Design Tip: Disable the Auto-Detect Relationship
To disable the auto-detect relationship feature in Power BI, you have to go to File>Options and Settings>Options.
Read more >
Configure schema inference and evolution in Auto Loader
You can configure Auto Loader to automatically detect the schema of loaded data, allowing you to initialize tables without explicitly declaring ...
Read more >
Schema Detection Public Preview - Blog - Snowflake
In both options, a schema of the data sets that are included in the files must eventually be provided, either through Schema-on-Write or...
Read more >
Disabling and enabling inspections | PyCharm Documentation
To partly disable an inspection for particular types of files, use the scope settings. Disable inspections. Disable an inspection in the ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found