Repository navigation
Harden and extend Yaml parsing and add Yaml.stringify - #10287
Open
effect-bot wants to merge 54 commits into
Open
effect-bot wants to merge 54 commits into
effect-bot wants to merge 54 commits into
Conversation
🦋 Changeset detectedLatest commit: deb32eb The changes in this PR will be included in the next version bump. This PR includes changesets to release 33 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
Contributor
Bundle Size AnalysisGenerated from PR build output; treat the content below as untrusted.
|
tim-smart
force-pushed
the
v4/next-minor
branch
from
November 3, 2026 20:54
2e13c53 to
5f5a4b3
Compare
effect-bot
force-pushed
the
v4/next-minor
branch
7 times, most recently
from
November 3, 2026 22:52
97a1ee1 to
10d44ad
Compare
effect-bot
force-pushed
the
agent/effect-bot/eff-3232-printer-round-trip
branch
from
November 3, 2026 23:14
60cde73 to
006a562
Compare
effect-bot
force-pushed
the
v4/next-minor
branch
from
November 3, 2026 23:39
2650b53 to
0a68f11
Compare
effect-bot
force-pushed
the
agent/effect-bot/eff-3232-printer-round-trip
branch
from
November 3, 2026 23:40
006a562 to
26e2c51
Compare
effect-bot
changed the base branch from
v4/next-minor
to
agent/architect-effect-bot/6a52aa9988ae
November 3, 2026 23:40
This was referenced Nov 3, 2026
Closed
effect-bot
force-pushed
the
agent/effect-bot/eff-3232-printer-round-trip
branch
from
November 3, 2026 23:43
26e2c51 to
58b2c97
Compare
effect-bot
force-pushed
the
agent/architect-effect-bot/6a52aa9988ae
branch
from
November 3, 2026 23:43
7a672f9 to
3b465fb
Compare
effect-bot
changed the base branch from
agent/architect-effect-bot/6a52aa9988ae
to
v4/next-minor
November 3, 2026 23:57
effect-bot
force-pushed
the
agent/effect-bot/eff-3232-printer-round-trip
branch
2 times, most recently
from
November 4, 2026 01:02
d1233b6 to
c05b323
Compare
effect-bot
force-pushed
the
v4/next-minor
branch
from
November 4, 2026 01:44
863f511 to
6d1f02e
Compare
effect-bot
force-pushed
the
agent/effect-bot/eff-3232-printer-round-trip
branch
from
November 4, 2026 02:08
32277cb to
3e92887
Compare
effect-bot
force-pushed
the
v4/next-minor
branch
from
November 4, 2026 02:27
6d1f02e to
e2514b1
Compare
The shorthand tags !!str, !!int, !!float, !!bool, !!null, !!seq and !!map resolve against the scalar as written, a mismatched node fails, and every other tag, including verbatim and non-specific tags, still fails.
Tags keep the token start for structure and comment scanning, a node's properties may continue on the next line and its anchor records the resolved value, and a node has at most one anchor and tag, no properties on an alias, and separation before flow content.
A scalar tag on a flow collection key fails like a tagged collection value, and a node starting with '&' must name its anchor.
…inter The printer's quoting rule and the parser's core tag resolution each spelled out the YAML 1.2 core schema; one table now serves both.
…indentless sequence
…get and marker quoting
…keys without values, and cap merged keys
Classify plain-safe strings in one pass with a prefilter before the core schema patterns, escape double-quoted strings by slicing between escapes, build error paths only when a failure happens, and cache indentation.
Scan lines and flow collections by character code instead of per-character regex tests and single-character strings. Find a line's comment and its mapping separator in one pass in makeLine, keep the separator on the line, and reuse it for sequence entries instead of scanning each line again. Avoid allocating trimmed copies for blank checks and untouched strings, skip the core schema patterns for plain scalars that cannot match them, and assign keys absent from the prototype chain directly instead of defining them.
effect-bot
force-pushed
the
agent/effect-bot/eff-3232-printer-round-trip
branch
from
November 4, 2026 04:14
0cf9e85 to
1b039ee
Compare
The printer now asks resolvePlain whether a spelling is a core scalar instead of keeping a second set of the schema patterns, the non-printable set has one code-unit definition shared by plain and block scalar checks, and the string whitespace predicate is folded into its code-unit form.
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.
The rest of the YAML expansion in one PR. #10271 (
Yaml.parseAll, directives, andResultfromYaml.parse) has already merged. This PR adds the parser hardening, new grammar, core schema tags, and the printer. It replaces #10276, #10279, #10282, #10283, #10284, #10285 and #10272, which were reviewed as separate stages and are now closed. Their commits are kept here unchanged.Parser
Input that used to be misread now fails or parses correctly
!!str,!!int,!!float,!!bool,!!null,!!seqand!!map.!!str 0x10is"0x10"and!!int "42"is42.!!int x,!!bool yesor!!seq {a: 1}.!custom), the non-specific tag!, verbatim tags (even for core tags), YAML 1.1 tags (!!binary,!!timestamp,!!set) and unknown!!tags.!inside a plain scalar (x!y) is still text.? key,{? a : 1},[? a]) fail with a clear error. The flow forms used to give the key"? a".*name : valueuses the anchored scalar as the key, where it used to be the literal text"*name". An alias to a collection used as a key fails. Anchors on keys are recorded.{0x10: 1}gives"16".tRuE,1_000and0X1Fare strings, and012,5.and.5e3are numbers.:ends a plain scalar.{a: b: c}and[a: 1: 2]fail instead of giving"b: c"and"a: 1: 2", and{http://x: 1}gives the key"http://x". A flow mapping key without a value that contains:({a:1}) fails, since YAML reads it as the key"a:1"while JSON-like input means{a: 1}. An unquoted[or{inside a flow plain scalar fails ([a[, b],{a[}), asns-plain-safe-inrequires.EncodingErrorinstead of a stack overflow.-. A-followed by white space or a flow indicator ([- 1],[1, -]) fails, asns-plain-firstin §7.3.3 requires.key: - valuefails. It used to be read as the string"- value".New grammar
- - value, §8.2.1), to any depth within the nesting limit.-\t1is an entry. A tab before a compact nested collection (-\t- 1) fails, because indentation can't use tabs.[a: 1, b]gives[{a: 1}, "b"], §7.4.1) and flow mapping keys without values ({a, b: 1}gives{a: null, b: 1}).Printer
null, booleans, numbers, strings, arrays and plain objects. The output is block style with keys in insertion order,{}and[]for empty collections, and a single trailing newline.parseand the core schema both read them back as the same string. Otherwise they are double-quoted with YAML escapes. Keys follow the same rule. Spellings that YAML 1.1 or lenient parsers read differently are quoted as well, such astRuE,1_000and---x. Multiline strings print as|,|-or|+literal block scalars when that is safe..inf,-.inf,.nanand-0.0round-trip.JSON.stringify:toJSONis applied, andundefinedproperties are omitted.JSON.stringify, nothing is silently dropped. Bigints, functions, symbols, non-plain objects withouttoJSON, and cycles fail with anEncodingErrorthat names the path.-, then an indented- item). Shared references print in full each time, without anchors.yaml2.9.1, which is added as a devDependency ofpackages/effectfor that purpose. Each test also reads the output back withYaml.parseorYaml.parseAll. The core schema patterns are shared between tag resolution and the printer.Remaining limits
The module docs describe these limits:
%TAGand other directives, and YAML versions other than 1.2, are not supported.Number.MAX_SAFE_INTEGERlose precision unless they are quoted.History
f5d52c1735joins them, and it is the only place their changes conflicted. The printer was added after the parser code inYaml.ts, and the printer tests after the parser tests. The printer branch's olderparsewas dropped.minorchangeset,.changeset/yaml-parse-stringify.md, is the release note for the whole PR. It replaces the seven per-stage changesets and describes the changes againstv4/next-minor, with a migration bullet for each input that now reads differently or fails.a: !!seq/&items/- 1), including properties that start on the line after the key. The printer trims a literal block's trailing line breaks with a backward scan instead of/\n+$/, which retried from every newline of an interior run and took seconds on 64,000 newlines followed by text.---or..., and the release note entries for input that now fails.stringify(scalar classification, double-quoting and error paths) and one forparseandparseAll(single-pass line scans, character-code checks and plain key assignment). Neither changes behavior, tests or the changeset.Validation
1b039eed5b:Yaml.test.tsand theMcpServertests pass, and the CLI, AI/MCP, ai-codegen and openapi-generator tests pass with 2,395 passed and 53 skipped.pnpm lint-fix,pnpm lint,pnpm check,pnpm jsdocs --checkand the fourYaml.tsdoctests pass.git range-diff.Closes EFF-3232