Uh oh!
There was an error while loading. Please reload this page.
fix(metadata-protocol): duplicatePackage no longer drops a locale from a two-tier i18n bundle (#7932) - #7993
Conversation
…e i18n bundle discriminator (#7932) `duplicatePackage`'s source-row scan deduped the scanned `sys_metadata` rows with a NUL-separated key built from the row's `type` and `name` only, keeping the org-scoped row over the env-wide one. That key is `(type, name)` with no discriminator, so for a type whose identity the spec declares as a pair it collapsed two rows that are two different things. `EmailTemplateDefinitionSchema` declares such a type: rows sharing a `name` but differing in `locale` form an i18n bundle resolved by `(name, locale)`. Within one org the collapse cannot happen — overlay uniqueness is `(type, name, organization_id, package_id)` and the table has no locale column — but across the env-wide and org tiers it can, and this scan is where the two tiers meet. An env-wide `auth.welcome` in `en-US` plus an org `auth.welcome` in `zh-CN` are two members of one bundle; the duplicate shipped one of them and reported success. Append the canonical-normalized discriminator when the type declares one and nothing otherwise — the shape #7774 gave `metaItemKey` — so every undiscriminated type keeps a byte-identical two-component key. Precedence is unchanged where it was ever meaningful: an org row still overrides the env-wide row of the same member. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01553EtKW75AGxDcCMyqkSEs
The latest updates on your projects. Learn more about Vercel for GitHub. 1 Skipped Deployment
|
📓 Docs Drift CheckThis PR changes 1 package(s): 3 hand-written doc(s) reference the affected code and may need an implementation-accuracy re-verification:
⛔ 1 release-owned page(s) also reference the affected code. These are read-only:
|
Uh oh!
There was an error while loading. Please reload this page.
Fixes#7932
domain:metadataPM seat on the implementing dev's behalf. The dev pushedclaude/issue-7932-duplicate-package-locale-key(fix + a 413-line test file,origin/mainalready merged in) but had no GitHub write access in its container — three of four sibling dispatches hit the same thing this shift. Body below is assembled from the dev's own changeset; its full report will be appended as a comment when it hands the text over. Flag any gap to me, not to them.The defect
Duplicating a package as an org-scoped caller copied one locale of a two-locale email-template customization and reported
success: true.duplicatePackage's source-row scan deduplicates the scannedsys_metadatarows with aNUL-separated key built from the row'stypeandnameonly, keeping the org-scoped row over the env-wide one. That key is(type, name)with no discriminator, so for a type whose identity the spec declares as a pair, it collapses two rows that are two different things.EmailTemplateDefinitionSchemadeclares exactly such a type: multiple rows with the samenamebut differentlocaleform an i18n bundle, resolved by(name, locale).Why the exposure is narrow — and why it is nevertheless real
sys_metadata's overlay uniqueness isidx_sys_metadata_overlay_active = (type, name, organization_id, package_id), and the table has no locale column — anemail_template's locale lives in themetadataJSON body. So:organization_id IS NULL) and org tiers they can, and this scan — widened to span both tiers in Four more strictorganization_idequalities left in protocol.ts — two measured (revertCommit / rollbackToPackageCommit), two unverified (duplicatePackage / reassignOrphanedMetadata) #7819 — is the one place the two tiers meet. An env-wideauth.welcomecustomized inen-USplus an org-scopedauth.welcomecustomized inzh-CNare two distinct bundle members; the scan kept only the org one.Registry-shipped (code-authored) members are unaffected — this scan reads
sys_metadataoverlays only, so the exposure is limited to templates customized at both scopes.The change
The dedup key now appends the canonical-normalized discriminator when the type declares one, and nothing otherwise — the same shape #7774 / PR #7931 (
7372d46) gavemetaItemKeyandmergePackageAwareOverlayfor theGET /meta/<type>list. Both tools were already in the file:itemDiscriminatorfrom@objectstack/metadata-coreand the localstoredRowDiscriminator, which skips the JSON parse entirely for an undiscriminated type.email_templateis the only type inITEM_KEY_DISCRIMINATORStoday, so every other type's key is byte-identical to what it was before — this change's blast radius is provable rather than argued, which was the review criterion.Precedence is unchanged wherever it was ever meaningful
en-US) member, so the bundle-blind and bundle-aware answers continue to agree for a single-member "bundle";organizationIddoor never ran this dedup and is untouched.Coverage
This path had no test coverage at all before this PR —
git grepof the dedup key returned onlyprotocol.tsitself. The newprotocol.duplicate-package-bundle-key.test.tsis 413 lines, built to the standard PR #7931 met for its sibling: both directions, plus per-arm reverse-verification attributing which cases go red under which half of the revert.Generated by Claude Code