redhat-developer / redhat-developer/vscode-yaml

YAML LSP Schema Validation Error with Custom Tags (e.g., !include)

Open
#1,145 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
TypeScript
Stars
829
Forks
260
Avg merge
5h 43m
Merged PRs (30d)
1

Description

Describe the bug

The YAML Language Server shows a schema validation error when encountering custom tag !include. While the underlying parser correctly accepts the !include tag as valid YAML, the schema validator fails to interpret the tag's value. Instead of understanding that !include ./libs.yaml resolves to an object, the validator tries to validate the literal string ./libs.yaml against the schema's type definition, which expects a full object. This creates a false positive error that breaks validation

Expected Behavior

The validation error is a false positive,

Current Behavior

The schema validator does not process the custom tag. It sees the !include tag's value ./libs.yaml as the final value. It then tries to validate that this string against the schema's "type": "object" requirement, which fails.

Steps to Reproduce

  1. Using the following schema :
{
  "type": "object",
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "properties": {
    "libs": {
      "type": "object",
      "description": "Library definitions",
      "additionalProperties": {
        "$ref": "#/$defs/library"
      }
    },
  }
}
  1. Create main YAML file associated with the schema
libs: !include ./libs.yaml
  1. The YAML LS will report an error similar to:
    Incorrect type. Expected "object". [YAML Schema]

Environment

  • Windows
  • Mac
  • Linux
  • other (please specify)
  • Extension version : 1.18.0
  • Vscode version : 1.103.2

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Reproduce the report with the supplied schema and libs: !include ./libs.yaml, then trace the YAML schema-validation path that handles custom tags. The issue names no files or tests; done means this example no longer produces an incorrect object-type error, with coverage for the regression.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript, yaml
Domain
tooling
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.