[DIT-13505]: YAML aliases are dropped by the i18n extractor - #9
Merged
laurakoye merged 2 commits intoAug 19, 2026
Conversation
jholiga
reviewed
Aug 19, 2026
jholiga
left a comment
Collaborator
There was a problem hiding this comment.
I found a few super edge cases with Claude that I noted. I wonder if it's worth checking out if there's any opportunity to lean more on the yaml parser that we import and call on line 17 of yaml-i18n.ts?
jholiga
approved these changes
Aug 19, 2026
laurakoye
merged commit Aug 19, 2026
7f4ead9
into
laura/dit-13480-capture-the-raw-literal-snapshot_text-in-resource-file
3 checks passed
laurakoye
deleted the
laura/dit-13505-yaml-aliases-are-dropped-by-the-i18n-extractor
branch
August 19, 2026 17:02
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.
Closes DIT-13505.
A YAML key whose value is an alias produced no candidate, so copy shared through anchors was invisible to the scan everywhere it was reused.
Why: an
Aliasnode has novalueproperty, only a reference, and the walker emits on nodes that have one.Decision
Aliases are emitted as value links.
farewellyields"Hello there"withsnapshot_text: "*hello"— the region actually written at that key. This is the first snapshot that shares no text with its value;source.includes(snapshot_text)still holds.Overwriting
*hellowould break the alias, so it joins the other spans that aren't safe to replace as-is in DIT-13481. Nothing on the write path changes here.Also: merge keys
<<: *defaultsis the sameAliasnode, so it was dropped too. Merged maps now fold into the merging path:<<: [*a, *b]works as well.Resolution follows the parser
Review caught three cases where the first pass resolved aliases differently from YAML itself. All three are fixed:
<<: *dplus an explicit key<<: [*a, *b]sharing a keyThe first one is the reason this changed shape: it reported a wrong value, not a missing one.
The anchor half is now the parser's job —
Alias.resolve(doc)finds "the last instance of the anchor before this node", which is exactly the rule a name → node map gets wrong. That deleted the anchor pre-pass entirely.Merge precedence stays ours, because the document tree keeps
<<as an ordinary pair — onlytoJS()resolves it, and that throws away the positionssnapshot_textneeds. The rule is one line: within a map the first candidate for a key wins, and explicit keys are considered before merged ones.Tests
toJS({ merge: true })does resolve all of this correctly, so it makes a good oracle. Five inputs — including all three cases above — assert that what we emit matches what the parser resolves, which covers the whole class rather than the instances that happened to get found.Two more pin where we deliberately diverge:
toJS()throws on an anchor cycle and on a dangling alias, and we keep going. Those tests assert both halves.The rest are unchanged: alias value and span, an alias reporting its own line rather than the anchor's, merge key, merge-key list, aliased sequence item, missing anchor skipped, self-referential anchor terminating, and one per bug above.
Plain scalars, block scalars and plural suffixes are untouched.
Verify locally
From the repo root on this branch:
The script has to sit in the repo root — the relative import resolves from there.
Expected — 7 candidates:
MISSINGin the first column is the acceptance criterion — every span must be findable verbatim in the file, aliases included.Before the fix — 4 candidates. Swap in the base version of the one file and rerun:
en.farewell,en.home.titleanden.planets.0vanish.Cleanup:
rm alias-check.ts && rm -rf /tmp/yamldemo