fix: blank lines inside mappings orphan all following entries - #14
Open
isutare412 wants to merge 1 commit into
Open
isutare412 wants to merge 1 commit into
isutare412 wants to merge 1 commit into
Conversation
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Author
|
@armsnyder Could you please check this? |
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.
Symptom
In any OpenAPI spec with blank lines between schema entries (very common in hand-written specs),
textDocument/definitionandtextDocument/referenceson$refvalues silently return nothing for everything below the first blank line insidecomponents. Blank lines between top-level sections are harmless (the next section is at indent 0 anyway), which is why the bundledtestdata/petstore.yamlnever caught it.Minimal reproduction — without the fix, a definition request on a
$refto#/components/schemas/Barreturns null becauseDocument.Locatecannot resolve it:Cause
In
Parse(internal/analysis/yaml/yaml.go), a blank line parses with indent 0 (len("") == 0). The parent-stack pop loop then treats it as an indent-0 mapping key: it pops the entire stack and registers the blank line as a new root under the empty key. Every line after the blank line is re-parented under that phantom root, soLocatecan no longer resolve it.Fix
Skip whitespace-only lines in the structure pass. They are still appended to
document.Linesfirst, becauseLinesis indexed by LSP line number ininternal/analysis/handler.go(document.Lines[params.Position.Line]).Verification
TestRefs_BlankLineBetweenSchemasfails before the fix (could not locate #/components/schemas/Bar) and passes after.go test ./...passes across the whole repo.$refresolution went from 0/103, 0/95, 0/103 to 103/103, 95/95, 103/103. A machine-generated spec without blank lines was 58/58 both before and after (no regression).