Repository navigation
fix(i18n): give cached $c-tr bindings fresh IDs and definitions on replay - #658
Merged
Merged
Conversation
…replay (#631) A `$c-tr` binding ID is built from the render ID of the component whose template holds the element. When that component is outside the cached output (a `<c-cache>` fragment in a page template, or slot content a caller passes to a cached component), the entry kept the first render's ID and no definition for it, so a cache hit sent the browser an ID the page never defined and the Vue app did not start. Export now asks the render cache which binding IDs the stored parts name, copies the bindings of components outside the entry into the record of the cache boundary, and replay renames them to fresh IDs like any binding written inside the entry. Export refuses an entry that names an ID no record holds, and replay skips an entry whose binding IDs are malformed or repeated, or whose binding needs a client provider the replaying render does not have. Fixes #631 Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
This was referenced Nov 14, 2026
Open
JuroOravec
force-pushed
the
fix/631-cache-i18n-binding
branch
from
November 14, 2026 14:12
127e6a1 to
ae626b0
Compare
This was referenced Nov 14, 2026
JuroOravec
added a commit
that referenced
this pull request
Nov 14, 2026
…ight merged changes (#682) Add one record under docs/security/reviews/ for each of the eight published 0.8.0 advisories (GHSA-4hj5, -8xvf, -7qpw, -g658, -x6rm, -h524, -xmx5, -xg8c) and for each of the pull requests that Mechanism 7, step 7 owes one: #610, #640, #651, #652, #653, #658, #674 and #675. Each record says only what the public pull request, the published advisory, the merged code and its tests show, and lists what was not checked. The reviews README describes how a record for a published advisory differs from a pull request record. The Mechanism 7 list in CLAUDE.md gains the two places that GHSA-7qpw added: parser rules browsers differ on, and the page's declared encoding. Co-authored-by: Claude Opus 5.5 <[email protected]>
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.
What was wrong
A
$c-trbinding ID is built from the render ID of the component whosetemplate contains the element. When that component is outside the cached
output, the cache entry kept the first render's ID and had no definition
for it. This happens with a
<c-cache>fragment inside a page templateand with slot content that a caller passes to a cached component. A
render that was served from the cache then sent the browser an ID the
page never defined. The browser threw
binding ... is not active, andthe Vue app did not start.
What this changes
It copies the bindings (and the
data-citry-i18n-bindingvalues thatlist them) of components outside the entry into the record of the cache
boundary. Replay renames them to fresh IDs like any binding written
inside the entry, so the page gets one definition for each ID its HTML
names.
OnRenderCacheExportContext.browser_binding_operands: thestring operand of every browser binding in the stored parts, grouped by
helper name. It has a default, so existing extensions keep working.
names an ID that no record holds, when one marker lists some IDs the
stored parts use and some they do not, or when the boundary has no
record to hold the outside bindings.
not look like
<render ID>~i18n-<number>(the number is at most 9digits), when an ID repeats in one record, or when a binding belongs to
a client provider outside the entry and the replaying render has none.
Before, the last case failed the request.
docs/design/i18n.mdanddocs/design/caching.mddescribe the newpayload content and the refusals.
CHANGELOG.mdhas an entry under Unreleased, Fixes.Tests
tests/test_i18n_cache.py(44 tests): a fragment with text andattribute bindings, a component cache with a caller's fill, a fragment
at the root of a child template, a provider inside the fragment, nested
fragments (outer miss with inner hit stores the outer entry), the same
key used twice, a fragment per loop item, a fragment inside a fill
passed to another component, a boundary with its own binding plus a
caller's fill binding, an entry made under an outside provider and
replayed without one, forged, repeated and over-long IDs, and the three
export refusals. Each guard was removed in turn to confirm a test
fails. The scenario tests fail on current
mainwith markers that haveno definition.
tests/test_ext_cache_typed_artifact.py: the operand grouping.tests/e2e/test_cache_replay_e2e.py: a Chromium test with aPagethat holds a fragment and a component whose root is
<c-cache>. Itchecks four fresh IDs on the second render, the texts, and that
$i18n.switchLocale('cs-CZ')translates every element. Onmainitfails with
binding ...~i18n-1 is not active.test_i18n_usage.py::test_render_cache_remaps_translation_binding_records_and_html_markersused the placeholder string for "ambient owner" as the provided client
owner. Replay drops a provide value that is not a render ID, so the new
check skipped the entry. The test now provides a valid ID.
Checks run
ruff check,ruff format --check, andmypy(host and--platform linux) pass on the changed files.test_ext_cache*,test_i18n*,test_extension*,test_events*,test_vue*): 20 failures, 4524 passed. The samefailures occur on current
mainwithout this change. They come fromthe local
citry_coreRust extension being older than the source (forexample "not enough values to unpack (expected 8, got 7)" and the
reserved-prefix tests from fix(parser): reject v-for and v-slot names with Citry's reserved prefixes #628), so CI with a fresh build is the real
check.
tests) passed before the rebase onto
main. I did not rerun them afterthe rebase, because the rebase did not touch them.
scripts/check.py, and the Rust gates were not runlocally.
Review
An independent reviewer went through the change at maximum effort, with a
separate security pass (places touched: markers for Citry's browser
code, JavaScript and JSON, translated messages) and a check against the
maintainers' advisory survey. It found no security hole and no confirmed
bug. Its performance, robustness, and test-gap findings were fixed and
re-checked, including a crash on a stored ID with thousands of digits
and the cost of export growing with the number of cached rows. A
separate prose review ran twice. After merge, the Mechanism 7 review
record in
docs/security/reviews/is still to be written.Open items
renamed. If a stored entry's parts and its i18n record disagree, it
still replays as a hit and the page can name IDs with no definition.
Writing such an entry needs write access to the cache, which
docs/design/caching.mdsection 7.1 already treats as trusted, andmainbehaves the same way. A reviewer also reproduced it with anunfixed worker writing entries that a fixed worker then reads. I do
not expect that across releases:
_RENDER_CONTRACTincludes theinstalled Citry version (
ext/cache/artifact.py:38-40) and replayrejects an entry with a different contract (
:761), so workers ondifferent versions do not replay each other's entries. The reviewer's
reproduction used two source trees with the same version string, and I
did not test across a real version bump. A follow-up could reject, at
replay, an entry whose stored markers or operands are not all renamed.
providesvalue forcitry_i18n_clientthat is notshaped like a render ID. Emission accepts any non-empty string, but
replay keeps only render-ID-shaped values. With such a value every
request skips the entry and stores a new one, so it never hits. The
page stays correct. Nothing in the package supplies the key this way.
export_render_cachereadsctx.instances[0]without a guard. Nobody could build an empty
instances.{"parent": depth}replayed at a differentdepth, and
simple=Truecomponents.Follow-ups: problems that exist without this change
data-cid="<fresh id>"to its root element (ext/events/cache.py:178),while a live prepared render skips it (
ext/events/emission.py:70-73).docs/design/caching.mdsection 7.1 says artifacts contain nooriginal render IDs, but the i18n payload keeps old binding IDs as the
names that replay renames from, for a component's own bindings too.
<c-i18n c-client>fails in the browser withan i18n fragment uses a different project runtimeState.configuration: the page and therevision write
formatsandparsersin a different key order, andthe runtime compares the JSON text.
Cacheon a component returned fromon_renderraisesUnsupportedPreparedViewon a hit (also without i18n).$c-trbindings is very slow, and the entry is then refused as too large.
values_expressionis accepted as anynon-empty string, while the part-level expression must match one a
live template wrote. The browser stores it as metadata and does not
run it, so this is an inconsistency, not a way to run code.
Fixes #631
🤖 Generated with Claude Code