Repository navigation
Conversation
ApiDOM 6.1.0 serializes an empty YAML node, such as the value of `key:` while it is being typed, as null, its value in YAML (speclynx/apidom#655). The element stays a string element, which is what the services and linter functions check, but the value they read from it with ApiDOM's toValue is then null, and what they do with a string throws or misreads it. On 6.1.0 an empty `$ref:` makes validation and document links throw, and completion at it throws; linter functions throw on an empty value, and the validation service drops their diagnostics; and a pattern rule tests the text "null", so an empty stepId, workflowId or name no longer gets its pattern warning. A consumer of 3.0.0 resolves ApiDOM 6.1.0 already. The services and linter functions now read values through a toValue of their own, which returns a string element's own value and what ApiDOM serializes for anything else, so an empty value reads as the empty string again. JSON Schema validation and dereferencing keep ApiDOM's toValue: they serialize the document, and null is its YAML value.
ApiDOM 6.1.0 fixes the external scanner of its tree-sitter YAML grammar (speclynx/apidom#646). A document nested about 253 levels deep overflowed the scanner's state buffer, and every later YAML parse in the process failed until it restarted. A language server shares that parser between documents, so one such document left an editor reporting a syntax error in every YAML document. The ApiDOM ranges move from ^6.0.6 to ^6.1.0 so that no install keeps 6.0.x, and a test validates a valid document after deeply nested ones; on 6.0.6 it fails with "memory access out of bounds". With 6.1.0, JSON Schema validation reads an empty YAML value as null, its value in YAML, as it already did for a document it parses with YAML.parse, and reports it where the schema expects a string; it read the empty string before. The lockfile drops unraw, which the YAML adapter no longer needs.
The dereferencing service takes its base URI from the first server, and read it from ApiDOM's serialization of the servers. Since ApiDOM 6.1.0 that serialization gives null for an empty YAML node, so an empty `url:` became the base URI null and dereferencing failed with `Error while dereferencing file "null"`, where 6.0.6 read the empty string and an AsyncAPI document dereferenced. An empty server, `- ` under OpenAPI servers or `prod: ` under AsyncAPI ones, serialized as null as well, and the service threw a TypeError reading its `url`. The service now reads the first server's url element with the services' own toValue, which gives the empty string again, and takes it as the base URI only when it is a string. A server without a url or with a null one, and an empty list of servers, leave the default base URI instead; these failed on 6.0.6 too, with the file "undefined" or "null", or a TypeError.
This branch has not been deployed
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.
ApiDOM 6.1.0 fixes a crash that matters to every long-running user of the language service, such as an editor: the external scanner of its tree-sitter YAML grammar overflowed on a document nested about 253 levels deep, after which every YAML parse in the process failed until it restarted (speclynx/apidom#646). Through the language service, a valid document validated after such a document reports "YAML syntax error". The second commit moves the ApiDOM ranges from
^6.0.6to^6.1.0, andtest/parse-deep-nesting.tsvalidates a valid document after deeply nested ones; on 6.0.6 it fails withRuntimeError: memory access out of bounds.6.1.0 also changes what ApiDOM's
toValuereturns for an empty YAML node such askey:, the state of a value while it is being typed:null, its value in YAML, where it returned the empty string (speclynx/apidom#655). The element stays a string element. The services and linter functions read values with thattoValueand use them as strings, and a fresh install of 3.0.0 already resolves 6.1.0, so this affects the published release. To measure it, the 510 YAML fixtures, and 6,041 variants of them with the values of one key, or the items of block sequences, emptied, went through every document operation: validation with the JSON Schema providers registered, code actions, symbols, links, semantic tokens, conversion and dereferencing, and completion, hover, definition and references at the emptied value. On 6.1.0, 3.0.0 throws in 262 operations where it did not on 6.0.6, among them validation and links with an empty$ref:, and completion at it, which is what fails two completion tests after the bare update. It also logs 515 linter function errors whose diagnostics the validation service drops, and pattern rules test the text "null", so an emptystepId,workflowIdornameloses its pattern warning.The first commit gives the services a
toValueof their own inutils.ts: a string element's own value, and what ApiDOM serializes for anything else. The services and linter functions import it instead of ApiDOM's; JSON Schema validation and the output of dereferencing keep ApiDOM's, since they serialize the document andnullis its YAML value. With it, on 6.1.0 the language service throws in none of those operations, logs no linter error, and returns the same semantic and syntax diagnostics as 3.0.0 on 6.0.6 in all 6,549 validated cases.test/empty-yaml-values.tspins an empty$ref:through validation and links, and the pattern warning of an emptystepId; both cases fail without the commit. On 6.0.6 the commit changes nothing, as ApiDOM'stoValuereturned a string element's own value there.One result changes for users. JSON Schema validation reads an empty YAML value as
null, as it already did when it parsed a document withYAML.parse, and reports it where the schema expects a string, in 4,181 of the cases; it read the empty string before. Dereferencing writesnullfor empty values.The third commit fixes the dereferencing service, which took its base URI from ApiDOM's serialization of the servers. On 6.1.0 an empty
url:became the base URInull, and dereferencing failed withError while dereferencing file "null", where 6.0.6 read the empty string; an empty server,-under OpenAPI servers orprod:under AsyncAPI ones, made the service throw aTypeErrorreading itsurl. The service now reads the first server's url element with the services'toValueand uses it only when it is a string, so an empty url is the empty string again, and a server without a url or with a null one, or an empty list of servers, leaves the default base URI; these failed on 6.0.6 too.test/empty-yaml-values.tsdereferences five such documents and fails without the commit. Over the fixture variants, the 43 documents with an empty server url that failed to dereference on 6.1.0 dereference again, and no other result of any operation changes.Problems of ApiDOM 6.1.0 remain that need a fix in ApiDOM, as they come from the same change inside it. When error recovery yields an empty key, which a scalar line directly before a
key: valueline does, so a key typed above an existing entry, the OpenAPI refractor throwsTypeError: Cannot read properties of null (reading 'take')fromisOpenApiExtension, and every operation on the document fails; 6.0.6 reported a YAML syntax error (test/fixtures/openapi-complete-filter.yamlis such a document). And reference resolution passes an empty$ref:to its URL functions asnull: an OpenAPI 3.0 Reference Object with an empty$ref:, which 6.0.6 dereferenced, now fails the whole dereference with aTypeError.Every job of
build.ymlpasses locally: commit messages, declarations, lint (the 11 warnings ofmain), types, 574 tests, the build, the retired-identifier search, the validator drift check, and the package contract check, whose SBOM lists 79 dependencies, the 3 copied files and 49 packages embedded in the browser bundle, which no longer containsunraw.