-
Notifications
You must be signed in to change notification settings - Fork 154
Description
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
- 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"
}-
Open a YAML File: Create or open a YAML file (e.g., test.yaml) that should match the pattern *.yaml.
-
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.
-
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.jsonSave 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.