Skip to content

fix(deps): update ApiDOM to 6.1.0 - #85

Open
frantuma wants to merge 3 commits into
mainfrom
frantuma/apidom-6-1-0
Open

frantuma wants to merge 3 commits into
mainfrom
frantuma/apidom-6-1-0

Conversation

@frantuma

@frantuma frantuma commented Oct 22, 2026 •

Copy link
Copy Markdown
Member

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.6 to ^6.1.0, and test/parse-deep-nesting.ts validates a valid document after deeply nested ones; on 6.0.6 it fails with RuntimeError: memory access out of bounds.

6.1.0 also changes what ApiDOM's toValue returns for an empty YAML node such as key:, 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 that toValue and 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 empty stepId, workflowId or name loses its pattern warning.

The first commit gives the services a toValue of their own in utils.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 and null is 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.ts pins an empty $ref: through validation and links, and the pattern warning of an empty stepId; both cases fail without the commit. On 6.0.6 the commit changes nothing, as ApiDOM's toValue returned 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 with YAML.parse, and reports it where the schema expects a string, in 4,181 of the cases; it read the empty string before. Dereferencing writes null for 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 URI null, and dereferencing failed with Error while dereferencing file "null", where 6.0.6 read the empty string; an empty server, - under OpenAPI servers or prod: under AsyncAPI ones, made the service throw a TypeError reading its url. The service now reads the first server's url element with the services' toValue and 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.ts dereferences 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: value line does, so a key typed above an existing entry, the OpenAPI refractor throws TypeError: Cannot read properties of null (reading 'take') from isOpenApiExtension, and every operation on the document fails; 6.0.6 reported a YAML syntax error (test/fixtures/openapi-complete-filter.yaml is such a document). And reference resolution passes an empty $ref: to its URL functions as null: an OpenAPI 3.0 Reference Object with an empty $ref:, which 6.0.6 dereferenced, now fails the whole dereference with a TypeError.

Every job of build.yml passes locally: commit messages, declarations, lint (the 11 warnings of main), 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 contains unraw.

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

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant