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

Having `tasks` as folder suffix in hierarchy causes Incorrect Type error

Open JakeHendy opened this issue 7 years ago • 9 comments

If you have a folder (anywhere in the hierarchy of the file) suffixed with tasks then you get Incorrect type. Expected "array"..

Examples:

foo
|- foo.yaml (fine)
|- tasks.yaml (fine)
|- tasks
  |- foo.yaml (Incorrect type)
|- tasks-test
  |- foo.yaml (fine)
|- test-tasks
  |- foo.yaml (Incorrect type)
  |- subdir
    |- foo.yaml (Incorrect type)
|- subdir
  |- tasks
    |- foo.yaml (Incorrect type)
  |- tasks.yaml (fine)

The files must have something in; I've been testing with AWSTemplateFormatVersion: "2010-09-09"

Error copied from VS Problems pane

{
	"resource": "/c:/jake.hendy/dev/tasks/task.yaml",
	"owner": "_generated_diagnostic_collection_name_#0",
	"severity": 8,
	"message": "Incorrect type. Expected \"array\".",
	"startLineNumber": 1,
	"startColumn": 1,
	"endLineNumber": 15,
	"endColumn": 1
}

Result from langauge server:

Params: {
    "textDocument": {
        "uri": "file:///c%3A/jake.hendy/dev/tasks/task.yaml",
        "languageId": "yaml",
        "version": 1,
        "text": "AWSTemplateFormatVersion: \"2010-09-09\"\r"
    }
}

JakeHendy avatar Dec 17 '18 12:12 JakeHendy

It looks like this is because when schemas are pulled from the schema store it tries to match folder structure/files to a schema. In this case, the tasks folder is trying to match tasks/foo.yaml to the ansible schema (http://schemastore.org/api/json/catalog.json).

Eventually, I'd like to see if its possible to manually override schemas so that if its pulled from the schema store and you have that structure (but aren't using it for ansible) then you can either set the schema for that file to no schema or set it to a different schema

JPinkney avatar Dec 31 '18 15:12 JPinkney

This has been driving me nuts. I am using concourse-ci, and have task definition files orgranized matching the recommended best practices:

project
|- ci
   |- pipeline.yml
   |- tasks
      |- task1.yml
      |- task2.yml

All my task files are showing up with this error like this. How can I make this extension properly recognize the valid YAML syntax?

kelbyers avatar Apr 01 '19 17:04 kelbyers

I believe it's because when we are pulling from the json schema store someone made a different schema match every YAML file underneath a tasks folder. If you set yaml.schemaStore.enable to false it won't automatically grab schemas from the schema store and you shouldn't run into this issue.

JPinkney avatar Apr 01 '19 17:04 JPinkney

still getting this and is 1/2 way through 2020

bitsofinfo avatar Jul 06 '20 14:07 bitsofinfo

I can confirm that this is still present in v0.10.1 - are there any workarounds?

darioleanbit avatar Sep 02 '20 09:09 darioleanbit

@darioleanbit https://github.com/redhat-developer/vscode-yaml/issues/145#issuecomment-478665119

"yaml.schemaStore": false

JPinkney avatar Sep 02 '20 11:09 JPinkney

@JPinkney as stated in your first comment, the enable part is needed in the key:

"yaml.schemaStore.enable": false

pfrayer avatar Oct 27 '20 17:10 pfrayer

@JPinkney as stated in your first comment, the enable part is needed in the key:

"yaml.schemaStore.enable": false

This worked for me. Thanks

TechnicallyJoe avatar Nov 02 '20 12:11 TechnicallyJoe

7 years, wow

alexey-pelykh avatar Apr 19 '25 14:04 alexey-pelykh