question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

When adding a yaml-schema that resides in the same workspace as the yaml-files it applies to, it is erroneously validated against itself

See original GitHub issue

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

  1. Create new project in VSCode
  2. Add file schema.yaml containing
type: object
properties:
  foo: 
    type: string
    description: A foo property
additionalProperties: false
required: [ 'foo' ]
  1. Add file instance.yaml containing
foo: bar
  1. Add vscode/settings.json containing
{
    "yaml.schemas": { 
        "http://json-schema.org/draft-07/schema#": ["/schema.yaml"],
        "./schema.yaml": [ "/instance.yaml" ]
    } 
}

Observe:

image

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

qux: quux

image

It is, correctly, not being validated against /schema.yaml.

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

image

Environment

  • Windows
  • Mac
  • Linux
  • other (please specify)

Issue Analytics

  • State:open
  • Created 2 years ago
  • Reactions:10
  • Comments:6 (1 by maintainers)

github_iconTop GitHub Comments

4reactions
corneliusroemercommented, Aug 12, 2022

This is a very annoying bug. Would be so good if this was fixed.

The workaround suggested by @gorkem does not work for me, see screenshot

I cannot unselect validation against itself.

image image
1reaction
gorkemcommented, Apr 23, 2022

This seems to be related to how the mappings are processed from settings. A workaround until a fix is available Is to remove the json-schema mapping from settings.json and use inlined mapping by adding # yaml-language-server: $schema=https://json-schema.org/draft-07/schema as the first line of the schema file.

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to configure YAML schema to make editing files easier
Figure 2 shows an example of file validation. Figure 2: Validate your file against your YAML schema to ensure that it has the...
Read more >
Configuration options | Yarn - Package Manager
List of all the configuration option for Yarn (yarnrc files)
Read more >
CLI (v2) workspace YAML schema - Azure Machine Learning
Note. The YAML syntax detailed in this document is based on the JSON schema for the latest version of the ML CLI v2...
Read more >
YAML Format - Configuration Management
1-compliant YAML format. A module consists of multiple configuration Source files, each of which can define config definitions. Each such definition specifies ...
Read more >
1.1.7 (core) / 0.17.7 (libraries)
Fixed an issue where Dagster failed to load a dagster.yaml file that ... where dbt Cloud jobs with dbt run and dbt run-operation...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found