fix: skip local sibling probe for non-file:// schemas#1235
Merged
datho7561 merged 1 commit intoredhat-developer:mainfrom Apr 17, 2026
Merged
Conversation
…file:// schemas When a schema is loaded from an https:// URL (e.g. via a VS Code YAML extension contributor), _preferLocalBaseForRemoteId extracts the basename from sub-schema $id values and probes for them as local siblings. This causes spurious HTTP requests that fail with 404 errors. For example, loading openapi.v3.1.yaml (with $id pointing to github.com/.../schema.yaml) from an https:// contributor causes a probe for <contributor-base>/schema.yaml, which does not exist. The companion function _resolveLocalSiblingFromRemoteUri already guards against this with `if (parentUri.scheme !== 'file') return undefined`. Apply the same scheme guard to _preferLocalBaseForRemoteId so the local sibling optimization only fires for file:// schemas where it makes sense. Made-with: Cursor
c21653a to
5497e5a
Compare
Contributor
Author
|
This has been broken by this: #1186 |
datho7561
approved these changes
Apr 17, 2026
Contributor
datho7561
left a comment
There was a problem hiding this comment.
Seems reasonable. I verified that the test fails before and passes after, and tested out the scenario locally manually.
Contributor
|
Thank you! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
_preferLocalBaseForRemoteIdinyamlSchemaService.tsunconditionally probes for local sibling files by extracting the basename from a sub-schema's$idand resolving it relative to the parent schema's load location. When schemas are loaded fromhttps://(e.g. via a VS Code YAML extension contributor), this generates spurious HTTP requests that fail with 404 errors.file://scheme guard so the local sibling optimization only fires for local file schemas, matching the existing guard in the companion function_resolveLocalSiblingFromRemoteUri.https://-loaded schema with a sub-schema whose$idbasename differs from the actual filename.Problem
When a schema contributor serves schemas from a remote host (e.g.
https://git.some-company.com/.../openapi/adsk.openapi.extensions.yaml), the YAML language server resolves$refs to sub-schemas likeopenapi.v3.1.yaml. That sub-schema has:_preferLocalBaseForRemoteIdextractsschema.yamlfrom this$idand probeshttps://git.some-company.com/.../openapi/schema.yaml— a file that doesn't exist. The same happens withswagger.v2.0.json(whoseidishttp://swagger.io/v2/schema.json#), producing a probe for.../openapi/schema.json.These probes are harmless (the function falls back correctly), but they generate noisy error logs and waste network round-trips through the contributor's content handler.
Fix
The companion function
_resolveLocalSiblingFromRemoteUrialready has a scheme guard:The same guard is now applied to
_preferLocalBaseForRemoteId: if the current base URI is notfile://, skip the local sibling probe entirely and fall through to standard$idresolution.Test plan
should not probe local sibling paths when schema is loaded from https://— fails before fix, passes afterMade with Cursor