redhat-developer / redhat-developer/vscode-yaml
When adding a yaml-schema that resides in the same workspace as the yaml-files it applies to, it is erroneously validated against itself
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 829
- Forks
- 260
- Avg merge
- 5h 43m
- Merged PRs (30d)
- 1
Description
Describe the bug
Version 0.17.0.
When you use a YAML-file as a schema in the same workspace as the files you validate reside, the language-server tries to validate the schema against itself. As shown below, globbing does not play into it.
(I have looked at https://github.com/redhat-developer/yaml-language-server/pull/427 which on the surface appeared to be related, but after setting up a test where globbing is not involved, I don't think so.)
Expected Behavior
A YAML schema should not validate against itself, unless specified by the glob pattern.
Current Behavior
A YAML schema validates against itself, even if yaml.schemas association does not specify it.
Steps to Reproduce
- Create new project in VSCode
- Add file
schema.yamlcontaining
type: object
properties:
foo:
type: string
description: A foo property
additionalProperties: false
required: [ 'foo' ]
- Add file
instance.yamlcontaining
foo: bar
- Add
vscode/settings.jsoncontaining
{
"yaml.schemas": {
"http://json-schema.org/draft-07/schema#": ["/schema.yaml"],
"./schema.yaml": [ "/instance.yaml" ]
}
}
Observe:

It is being validated against itself. If you add yet another file instance2.yaml containing
qux: quux

It is, correctly, not being validated against /schema.yaml.
Edit: instance.yaml on the other hand, is, correctly, being validated against `/schema.yaml'

Environment
- Windows
- Mac
- Linux
- other (please specify)
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Reproduce the issue with vscode/settings.json, schema.yaml, and instance.yaml using the documented yaml.schemas associations. Start by tracing the language server's schema selection and validation flow for a schema in the same workspace. Done means schema.yaml is not validated against itself unless its association explicitly matches it, while instance.yaml remains validated.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript, vscode, yaml
- Domain
- tooling
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100