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

Schema error when there are both local (path) and remote (URI) schemas that match a file

Open Ark-kun opened this issue 4 years ago • 2 comments

Describe the bug

VSCode validates YAML files against configured schemas.

Schemas might be local or remote. //Schema paths with or without URI schema

There might be multiple schemas that match a given file.

When there is any number of local schemas that matches a file, the validation works.

When there is a any number of URI-referenced schemas that matches a file, the validation works.

When there is a local schema that matches a file plus any number of URI-referenced schemas, the validation stops working.

Expected Behavior

I expect the validation behavior to be consustent.

Current Behavior

Problems loading reference 'a:/schema.json': Unable to load schema from 'a:/schema.json': No content.YAML(768)

Steps to Reproduce

  1. Add a YAML file (e.g. component.yaml) with some valid content
  2. Modify VSCode settings to add local schema that matches the file.
  3. The file validates against the schema.
  4. Modify VSCode settings to add URI-based schema path that matches the file. The URI might be http:// or file://
  5. The file immediately stops validating with the following error: Problems loading reference 'a:/schema.json': Unable to load schema from 'a:/schema.json': No content.YAML(768)
  6. This error is only thrown for local schemas when there are any other URI-based schemas matching the same file. Additional local schemas do not seem to trigger the issue.
    "yaml.schemas": {
        "A:\\component_spec.json_schema.json": "component.yaml",
        "https://raw.githubusercontent.com/Cloud-Pipelines/component_spec_schema/master/component_spec.json_schema.json": "component.yaml",
        "file:///A:\\component_spec.json_schema.json": "component.yaml",
    }

Environment

  • [x] Windows
  • [ ] Mac
  • [ ] Linux
  • [ ] other (please specify)

Ark-kun avatar May 30 '21 01:05 Ark-kun

Hmm, I can't reproduce on linux with:

"yaml.schemas": {
        "/home/jpinkney/Documents/test/foo/schema.json": "test.yaml",
        "./test/foo/schema.json": "test.yaml",
        "file:///home/jpinkney/Documents/test/foo/schema.json": "test.yaml",
},

I wonder if it might be a windows issue. When I get a chance I'll get out my windows box and check it again

JPinkney avatar Jun 01 '21 12:06 JPinkney

I think there might be some issue with how the extension handles the paths on Windows (probably due to changing those paths from their original strings). It's still surprising that the presence of other URIs affects the behavior.

Ark-kun avatar Aug 26 '21 19:08 Ark-kun