You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Nov 4, 2026. It is now read-only.
Repository navigation
Commit 405e808
Browse filesBrowse the repository at this point in the historyBrowse files
fix(i18n): pickLocalized reads own properties only and takes only string values on every limb (#3907) (#4359)
Four of the six limbs — exact tag, base language, `default`, `en` — used bare
bracket access, so a locale naming an `Object.prototype` member resolved to that
member and rendered its source text as the label, and a non-string value
short-circuited the chain into `[object Object]`. Both guards now apply
uniformly; a guarded limb misses rather than aborting, so the chain continues.
Zero change for any real BCP-47 tag, which collapses the two departures the
backend twin `resolveI18nLabel` (objectstack#6765) recorded against this
function to zero. The parity table now pins that convergence.
Claude-Session: https://claude.ai/code/session_017Qqyix2QcnpUC9XeYVDzx3
Co-authored-by: Claude <noreply@anthropic.com>
`pickLocalized` reads own properties only, and takes only string values, on every limb
6
+
7
+
The resolver read four of its six limbs — the exact tag, the base language, `default` and `en` — with a bare bracket access. Bare access walks the prototype chain, so a locale that happened to name an `Object.prototype` member resolved to that member and the function stringified it into the label: `pickLocalized({ en: 'Pricing' }, 'constructor')` returned `function Object() { [native code] }`, and the same held for `toString`, `valueOf`, `hasOwnProperty`, `isPrototypeOf`, `propertyIsEnumerable` and `toLocaleString`. Those same four limbs also skipped the `typeof === 'string'` filter the regional and last-resort limbs already applied, so a non-string value short-circuited the chain and rendered as `[object Object]`.
8
+
9
+
Both guards now apply uniformly. A guarded limb **misses** rather than aborting the resolution, so an unusable entry falls through to the next limb exactly as an absent one does — `pickLocalized({ en: 'Pricing' }, 'constructor')` is now `'Pricing'` (the `en` limb), and only a map with no usable entry at all resolves to `''`. An empty-string value is still a hit, because `''` is a label the author wrote.
10
+
11
+
No real language tag can observe this: no BCP-47 tag is an `Object.prototype` member, and the inline locale map is declared `z.record(<tag>, z.string())`, so every in-contract input resolves byte-identically to before. What it changes is agreement with the backend twin `resolveI18nLabel` (objectstack#6765), which shipped with exactly these two narrowings recorded as deliberate departures from this function because on a server the locale can arrive in an `Accept-Language` header. That recorded rule divergence is now zero; the only remaining difference is how each side spells a miss (`''` here for a text node, `undefined` there for a producer's fallback chain), which is pinned as an identity in the cross-resolver parity table.
0 commit comments