yaml-language-server
yaml-language-server copied to clipboard
"Problems loading schema" with local schema reference
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
- create schema file
- create yaml file
- 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)
Just tested this out on 0.18.0 and can reproduce. Adding the bug label
FTR, I can reproduce the same issue in Mac (macOs Big Sur 11.4) when using v0.20.0
Any updates or workarounds for this?
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.