yaml-language-server icon indicating copy to clipboard operation
yaml-language-server copied to clipboard

"Problems loading schema" with local schema reference

Open de-code opened this issue 3 years ago • 4 comments

Describe the bug

Assuming the following simple yaml and schema:

file.schema.json:

{
  "type": "object",
  "properties": {
    "test": {"type": "string"}
  }
}

file.yml:

# yaml-language-server: $schema=file.schema.json
test: "value"

Then this frequently results in the following error message:

Problems loading reference 'schemaservice://combinedschema/file.schema.json': Unable to load schema from 'schemaservice://combinedschema/file.schema.json': No content.

Sometimes changing the schema filename to something like ./file.schema.json or /absolute/path/to/file.schema.json makes it temporarily work but is very unreliable (e.g. on changing the schema or yaml file).

Putting it into the VS Code settings has the same behaviour.

I also tried to disable "Automatically pull available YAML schemas from JSON Schema Store". Toggling that settings may also allow it to work temporarily.

Expected Behavior

It should load the referenced schema and validate against it.

Current Behavior

Frequently getting:

Problems loading reference 'schemaservice://combinedschema/file.schema.json': Unable to load schema from 'schemaservice://combinedschema/file.schema.json': No content.

Steps to Reproduce

  1. create schema file
  2. create yaml file
  3. reference schema file in yaml file, then it may or may not work (try saving the yaml or schema file)

Environment

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

de-code avatar Apr 29 '21 14:04 de-code

Just tested this out on 0.18.0 and can reproduce. Adding the bug label

JPinkney avatar Apr 29 '21 14:04 JPinkney

FTR, I can reproduce the same issue in Mac (macOs Big Sur 11.4) when using v0.20.0

someth2say avatar Jun 25 '21 11:06 someth2say

Any updates or workarounds for this?

colincadams avatar Sep 22 '21 19:09 colincadams

Was anyone able to find a workaround for this bug? I mentioned in #694 how this is hindering maintenance of our own schemas.

I even tried to pull full file:///... paths in the settings.json file but apparently it has no effect, the loader still resolves them as relative.

ssbarnea avatar Apr 05 '22 10:04 ssbarnea