Skip to content

yaml-language-server Schema Configuration Not Working in Global Settings #1158

@QiuminGe

Description

@QiuminGe

Issue Title: YAML Language Server Global Schema Configuration Not Working with Absolute Paths

Description

The YAML language server (yaml-language-server) fails to recognize custom JSON schemas when configured globally using absolute paths in the yaml.schemas setting within JupyterLab's LSP configuration. However, the same schema works correctly when specified per-file using the modeline comment (# yaml-language-server: $schema=...).

This indicates a path resolution issue where the global configuration does not properly handle absolute filesystem paths for schema associations, while relative paths or modeline directives function as expected .

Symptoms:
• No schema-based validation, autocompletion, or hover information occurs in YAML files when using absolute paths in global settings.

• The language server shows no error messages in logs, suggesting silent failure in schema loading.

• Switching to modeline comments immediately resolves the issue.

Reproduce

  1. Configure Global Schema: In JupyterLab's LSP settings jupyterlab-settings
    {
        "language_servers": {
            "yaml-language-server": {
                "serverSettings": {
                    "yaml.schemas": {
                        "/home/jovyan/work/rules/demo/sigma-detection-rule-schema.json": "*.yaml"
                    },
                    "yaml.trace.server": "verbose"
                }
            }
        },
        "loggingConsole": "browser",
        "loggingLevel": "debug",
        "logAllCommunication": true,
        "setTrace": "verbose"
    }
  1. Open a YAML File: Create or open a YAML file (e.g., test.yaml) that should match the pattern *.yaml.

  2. Test Validation: Enter content that should trigger schema validation errors (e.g., invalid keys or types according to your schema). Observe that no validation errors or warnings appear.

  3. Compare with Modeline: Add a modeline at the top of the same YAML file:

    # yaml-language-server: $schema=/home/jovyan/work/rules/demo/sigma-detection-rule-schema.json

Save the file. Now, schema validation errors should immediately appear, confirming the schema itself is valid and the server is functional .

Expected behavior

The global yaml.schemas configuration should correctly load and apply the JSON schema from the specified absolute path to all matching YAML files (*.yaml in this case), providing validation, autocompletion, and hover information seamlessly .

Specifically:
• Schema validation should trigger automatically for all YAML files matching the glob pattern.

• The behavior should be consistent with using the modeline comment, but applied globally to all relevant files.

• The language server should not silently ignore the configuration; any errors in path resolution should be logged.

Context

• Operating System and version: Linux (Containerized environment, e.g., JupyterPod)

• Browser and version: Not specified, but issue is backend/server-related.

• JupyterLab version: 4.4.9

• Language server and version: yaml-language-server v1.19.2 (installed globally via npm)

Required: installed server extensions

Required: installed lab extensions

Troubleshoot Output

Command Line Output

Browser Output (recommended for all interface issues)

Additional Context:
• The problem likely stems from how the yaml-language-server resolves paths in a workspace context. Documentation suggests that schema paths in global settings should often be relative to the project root rather than absolute . However, absolute paths should still be supported, especially when explicitly defined.

• This behavior creates a significant usability gap, as users must manually add modelines to every file instead of leveraging global configuration for project-wide schema management.

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