Skip to content

Fix schema priority lookup for normalized file URIs - #1312

Merged
datho7561 merged 1 commit into
redhat-developer:mainfrom
shin19991207:fix-1274
Jul 31, 2026
Merged

Fix schema priority lookup for normalized file URIs#1312
datho7561 merged 1 commit into
redhat-developer:mainfrom
shin19991207:fix-1274

Conversation

@shin19991207

@shin19991207 shin19991207 commented Jul 31, 2026

Copy link
Copy Markdown
Member

What does this PR do?

Before the fix, schema registration normalizes URIs to skip encodings, however, schema priorities were stored using the original URI. For an encoded Windows file URI, this produced different keys:

Priority key:  file:///c%3A/Users/.../schema.json
Registered ID: file:///c:/Users/.../schema.json

As a result, the configured schema's priority could not be found and defaulted to 0. Another matching schema could then incorrectly take precedence over the schema configured through yaml.schemas.

This PR normalizes URIs consistently when recording schema priorities, ensuring encoded and unencoded forms of the same URI use the same key.

What issues does this PR fix or reference?

Related to redhat-developer/vscode-yaml#1274

Is it tested? How?

  • New automated tests
  • Tested manually on Mac using the following setting:
    "yaml.schemas": {
        "file:///Users/.../encoded%3Aschema.json": "test.yaml",
        "file:///Users/.../schema.json": "test.yaml"
    }
    Expected test.yaml to be validated against Multiple JSON Schemas (both encoded:schema.json and schema.json), instead of just schema.json.

Signed-off-by: Morgan Chang <shin19991207@gmail.com>
@shin19991207
shin19991207 requested a review from datho7561 as a code owner July 31, 2026 19:00
@shin19991207 shin19991207 changed the title [WIP] Fix schema priority lookup for normalized file URIs Fix schema priority lookup for normalized file URIs Jul 31, 2026

@datho7561 datho7561 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I confirmed that overriding the schema with an encoded colon causes it to not be used when there's two schemas assgined to a file, and that this fixes that.

I'll play around with it on Windows too to see if I can replicate that problem and if this fixes it. Do you want to merge this as-is, or wait to hear back from phaumer?

@shin19991207

Copy link
Copy Markdown
Member Author

@datho7561 I think this PR can be merged as-is. I'll open another PR for the original reported issue when we can actually reproduce and identify the issue.

@datho7561 datho7561 added the bug label Jul 31, 2026
@datho7561 datho7561 added this to the 1.25.0 milestone Jul 31, 2026
@datho7561

Copy link
Copy Markdown
Contributor

Sounds good, let's merge, then

@datho7561 datho7561 moved this to Pending review in Java Tooling Jul 31, 2026
@datho7561
datho7561 merged commit 538c8ab into redhat-developer:main Jul 31, 2026
4 checks passed
@github-project-automation github-project-automation Bot moved this from Pending review to Done in Java Tooling Jul 31, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

2 participants