Fix handling of absolute local schema paths from yaml.schemas and yaml/get/jsonSchema StackOverflow#1260
Merged
Merged
Conversation
Signed-off-by: Morgan Chang <shin19991207@gmail.com>
Signed-off-by: Morgan Chang <shin19991207@gmail.com>
Signed-off-by: Morgan Chang <shin19991207@gmail.com>
yaml.schemasyaml.schemas and yaml/get/jsonSchema StackOverflow
2 tasks
Signed-off-by: Morgan Chang <shin19991207@gmail.com>
Signed-off-by: Morgan Chang <shin19991207@gmail.com>
Signed-off-by: Morgan Chang <shin19991207@gmail.com>
datho7561
approved these changes
May 22, 2026
Contributor
datho7561
left a comment
There was a problem hiding this comment.
Looks good! Thanks, Morgan!
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.
What does this PR do?
Fixed handling of absolute local schema paths from
yaml.schemasWhen multiple schemas with absolute local paths matched the same YAML file, the paths were kept as plain filesystem paths instead of being normalized to
file://URIs before schema registration.This causes problem when a YAML file matches multiple schemas:
schemaservice://combinedSchema/.../Users/.../schema.jsonagainst the internalschemaservice://combinedSchema/...URI, producing invalid references likeschemaservice:///.../schema.jsonUnable to load schema from 'schemaservice:///...': No content.This PR fixes normalizes absolute local paths from
yaml.schemastofile://URIs before schema registration. This ensures schema registration uses the correct local file URI, so schema validation and schema selection (schema picker) works properly.Fixed
yaml/get/jsonSchemaStackOverflowThe problem was that the schema picker (status bar) in
vscode-yamlcallsyaml/get/jsonSchemaonly wanting to get schema metadata such as schema URI, name, description, and versions. However, theyaml/get/jsonSchemahandler in YLS was using the full schema resolution path through thegetSchemaForResource(). Since this path is intended for validation, it can resolve combined schemas and walk complex$refgraphs. When a YAML file matched multiple "large" or "complex" schemas, the metadata request could end up doing deep schema resolution just to render the UI, which could cause a StackOverflow:Since
yaml/get/jsonSchemais used for schema status UI and only needs display metadata for the schemas associated with the current YAML doc, this PR adds a lightweight lookup path for that request to return metadata only without fully resolving the schemas.What issues does this PR fix or reference?
Fixes redhat-developer/vscode-yaml#1249
Related to redhat-developer/vscode-yaml#1253
Is it tested? How?
To verify absolute local paths from
yaml.schemasis registered correctly:/Users/.../asdf.yaml. Verify validation works and no error appears likeProblems loading reference 'schemaservice:///...': Unable to load schema from 'schemaservice:///...': No content..Multiple JSON Schemas, verify the schemas are shown asfile:///...URIs, notschemaservice:///...URIs.To verify
yaml/get/jsonSchemadoes not cause StackOverflow:[Trace - 3:22:55 PM] Received response 'yaml/get/jsonSchema - (153)' in 22ms. Request failed: Request yaml/get/jsonSchema failed with message: Maximum call stack size exceeded (-32603).