microsoft / microsoft/monaco-editor

[Bug] Monaco bundles outdated vscode-json-languageservice causing Draft 2020-12 schema errors in browser

Open
#5,172 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
JavaScript
Stars
46.8k
Forks
4.1k
Avg merge
17h 58m
Merged PRs (30d)
1

Description

Reproducible in vscode.dev or in VS Code Desktop?
  • Not reproducible in vscode.dev or VS Code Desktop
Reproducible in the monaco editor playground?
Monaco Editor Playground Link

https://microsoft.github.io/monaco-editor/playground.html?source=v0.55.1#XQAAAALjAQAAAAAAAABBqQkHQ5NjdMjwa-jY7SIQ9S7DNlzs5W-mwj0fe1ZCDRFc9ws9XQE0SJE1jc2VKxhaLFIw9vEWSxW3yscw0J8tR_YWJK-4JiwXYApNXu3LIJYp_q_KnzpC7M7q5vQEXpC8rIYhdOupAfwlq6nKlWmk0jDLZk7jHmVjhXBqB1AXT0U82uqgzBtwhdXxojDasjV6Y-2UfNzfni9Lmw3fcEf3JaGFwVGah6B0Zl4HKF9cIhYFRs8D20X9MEeX25FwUsa1H4Sw-f9dpjVEdZYdJGGU37gd2_7-f2pDFZyM5qRsoU-mriWGXZcF06BxxFODX5SGJ32r5BoM0naBABi1UurpfpkvyYvRI9kjOd7BBLOjOIaYodvrm65OLi_xQIwYMNz9hc4vXtHCRf18RUZX21dAZ2urtTT9F5MY

Monaco Editor Playground Code
monaco.languages.json.jsonDefaults.setDiagnosticsOptions({
    validate: true,
    schemas: [{
        uri: "https://json-schema.org/draft/2020-12/schema",
        fileMatch: ["*"],
    }]
});

monaco.editor.create(document.getElementById("container"), {
    value: JSON.stringify({
        "$schema": "https://json-schema.org/draft/2020-12/schema",
        "type": "object"
    }, null, 2),
    language: "json"
});
Reproduction Steps
  1. Open the Monaco Editor Playground.
  2. Set the JSON diagnostics to use the Draft 2020-12 meta-schema URI.
  3. Create a JSON file using that $schema.
  4. Observe the validation markers.
Actual (Problematic) Behavior

Monaco 0.55.1 bundles vscode-json-languageservice@5.3.11.
When editing JSON schemas using Draft 2020-12, the editor:

  • attempts to fetch the meta-schema in the browser, resulting in
    No schema request service available
  • emits $dynamicRef warnings that were removed in newer language service versions
Expected Behavior

Monaco should bundle a version of vscode-json-languageservice that includes the Draft 2020-12 fixes (>= 5.6.3), as already shipped in VS Code, so that:

  • the Draft 2020-12 meta-schema is bundled locally
  • the $dynamicRef warning is removed
  • no remote schema fetch is attempted in browser environments
Additional Context

This is caused by the version of vscode-json-languageservice currently bundled in Monaco (v0.55.1 uses v5.3.11).

The fixes for native Draft 2020-12 support (including the bundled flat schema and warning removal) were implemented in vscode-json-languageservice v5.6.3 (see PRs 294(https://github.com/microsoft/vscode-json-languageservice/pull/294) and 295( https://github.com/microsoft/vscode-json-languageservice/pull/295 ) in that repository).

This issue was identified during development for the JSON Schema Organization (see: json-schema-org/tour#103). Upgrading this dependency will significantly improve the experience for anyone using modern JSON Schema drafts in standalone Monaco environments.

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

Start with Monaco's dependency declaration for vscode-json-languageservice and reproduce the supplied Monaco Editor Playground example. Done means the bundled version is at least 5.6.3, Draft 2020-12 is handled locally, and the browser no longer reports a missing schema request service or the obsolete $dynamicRef warning.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript, vscode
Domain
devtools, frontend
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.