fix(vscode-yaml): handle incorrect uri parsing upon retrieving schema content

Issue: Web IDE Extension Marketplace - YAML Extension ... (#407 - closed)

What does this MR do and why?

This MR attempts to address the following concern:

I noticed that when I had both local and remote schemas targeting the same file, it generated an error as it wasn't able to merge the schemas, since local was missing. I tried having local schemas in Workspace level, remote schemas at workspace level. As expected, it clashed and showed an error. However when I reloaded, only the remote one was applied without error.

See discussion for full context.

I found that this behavior occurs even when the schemas don't target the same file and even when the local and remote schemas are defined in the same settings file (either workspace or user). In the presence of a remote schema, the vscode-yaml extension passes the following URI to requestSchemaContent: gitlab-web-ide:/~/path/to/schema.json instead of what is defined in the settings (gitlab-web-ide://~/path/to/schema.json). This causes the Uri to be parsed incorrectly– including the authority (~) as a part of the path.

This MR solves for this by removing the /~ if it exists at the beginning of the Uri path.

MR acceptance checklist

Please evaluate this MR against the MR acceptance checklist. It helps you analyze changes to reduce risks in quality, performance, reliability, security, and maintainability.

Screenshots or screen recordings

Screenshots are required for UI changes, and strongly recommended for all other merge requests.

Before After
before after

How to set up and validate locally

  1. Let's use this schema for the remote schema

  2. Open a project in the Web IDE and create the following files:

    1. A local JSON schema: create a my-schema.json file at the root of the directory and populate with the above schema contents
    2. A .yaml or .yml file
  3. Add the following configuration to user/workspace settings as you please and save:

    "yaml.schemas": {
       "https://json.schemastore.org/clasp.json": ["*.yaml", "*.yml"],
       "gitlab-web-ide://~/my-schema.json": ["*.yaml", "*.yml"]
    }
  4. Open the .yaml file and observe the schema labels loaded. Click on each of them and it should load the schema content 🎉

Edited by Cindy Halim

Merge request reports

Loading