Skip to content

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

@peaceful-wanderer

Description

@peaceful-wanderer

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions