Skip to content

fix: skip local sibling probe for non-file:// schemas#1235

Merged
datho7561 merged 1 commit intoredhat-developer:mainfrom
Kosta-Github:fix/prefer-local-base-scheme-guard
Apr 17, 2026
Merged

fix: skip local sibling probe for non-file:// schemas#1235
datho7561 merged 1 commit intoredhat-developer:mainfrom
Kosta-Github:fix/prefer-local-base-scheme-guard

Conversation

@Kosta-Github
Copy link
Copy Markdown
Contributor

@Kosta-Github Kosta-Github commented Apr 17, 2026

Summary

  • _preferLocalBaseForRemoteId in yamlSchemaService.ts unconditionally probes for local sibling files by extracting the basename from a sub-schema's $id and resolving it relative to the parent schema's load location. When schemas are loaded from https:// (e.g. via a VS Code YAML extension contributor), this generates spurious HTTP requests that fail with 404 errors.
  • Added a file:// scheme guard so the local sibling optimization only fires for local file schemas, matching the existing guard in the companion function _resolveLocalSiblingFromRemoteUri.
  • Added a test that reproduces the issue: an https://-loaded schema with a sub-schema whose $id basename 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 like openapi.v3.1.yaml. That sub-schema has:

$id: https://github.com/OAI/OpenAPI-Specification/blob/main/schemas/v3.1/schema.yaml

_preferLocalBaseForRemoteId extracts schema.yaml from this $id and probes https://git.some-company.com/.../openapi/schema.yaml — a file that doesn't exist. The same happens with swagger.v2.0.json (whose id is http://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 _resolveLocalSiblingFromRemoteUri already has a scheme guard:

if (parentUri.scheme !== 'file') return undefined;

The same guard is now applied to _preferLocalBaseForRemoteId: if the current base URI is not file://, skip the local sibling probe entirely and fall through to standard $id resolution.

Test plan

  • New test should not probe local sibling paths when schema is loaded from https:// — fails before fix, passes after
  • Full test suite passes (1286 passing, 0 failing)

Made with Cursor

@Kosta-Github Kosta-Github requested a review from datho7561 as a code owner April 17, 2026 12:50
…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
@Kosta-Github Kosta-Github force-pushed the fix/prefer-local-base-scheme-guard branch from c21653a to 5497e5a Compare April 17, 2026 12:54
@Kosta-Github
Copy link
Copy Markdown
Contributor Author

This has been broken by this: #1186

Copy link
Copy Markdown
Contributor

@datho7561 datho7561 left a comment

Choose a reason for hiding this comment

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

Seems reasonable. I verified that the test fails before and passes after, and tested out the scenario locally manually.

@datho7561 datho7561 added the bug label Apr 17, 2026
@datho7561 datho7561 added this to the 1.23.0 milestone Apr 17, 2026
@datho7561 datho7561 merged commit 3904d0a into redhat-developer:main Apr 17, 2026
4 checks passed
@datho7561
Copy link
Copy Markdown
Contributor

Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants