Repository navigation
fix(service-messaging): a notification template read for a recipient locale with no row tries the stack's declared fallback before en - #29048
Conversation
… declared fallback locale NotificationTemplateStore walked the named tag, its primary subtag, then 'en', and never read the stack's i18n.fallbackLocale. The plugin now hands the store the i18n service's getFallbackLocale under a module-private key, read at each resolve; the ladder tries the declared fallback and its primary subtag before DEFAULT_LOCALE. A host with no i18n service answers as before. Co-Authored-By: Claude <noreply@anthropic.com>
Co-Authored-By: Claude <noreply@anthropic.com>
…te declared fallback Co-Authored-By: Claude <noreply@anthropic.com>
…delete through the dispatch predicates Co-Authored-By: Claude <noreply@anthropic.com>
📓 Docs Drift CheckThis PR changes 1 package(s): 1 hand-written doc(s) NAME something this change touched and may need an implementation-accuracy re-verification:
⛔ 2 release-owned page(s) also name something this change touched. These are read-only:
What this run could not see
Coarse fallback — 6 page(s) merely mention a changed package (the pre-#9192 predicate, kept for the deliberately-wide backstop): Which tree this was computed onThis run read A worktree cut from an older # while this PR is open — GitHub drops the merge commit once it closes
git fetch origin 1156554e9d23d7f4f51e8bcfd6c242638a095b7d && git checkout 1156554e9d23d7f4f51e8bcfd6c242638a095b7d
# afterwards, rebuild it from the two parents, which stay fetchable
git fetch origin 0be247ce8b91ba3b9a3ce7235491b28a986b039a 1c8f2f69817b8c0ac1a43bb8dc2d3ed3f1388720 && git checkout -B drift-repro 0be247ce8b91ba3b9a3ce7235491b28a986b039a && git merge --no-ff 1c8f2f69817b8c0ac1a43bb8dc2d3ed3f1388720
node scripts/docs-audit/affected-docs.mjs --json 0be247ce8b91ba3b9a3ce7235491b28a986b039a
|
|
domain:server#5 · os-project-manager · session_01FEkQ5oc56xChD6Wrc4cGSt 席位核对ACCEPT · The maintainer's standing authorisation for landing reviewed PRs, verbatim: 「按照 pm-dispatch 规则复核过的都授权」. 席位意见:与 diff 相符。通知模板在收件人语言没有对应行时,先试站点声明的回退语言(及其主语言),再退到 en,与邮件模板一致;没有 i18n 服务、未指定语言或包外构造的调用照旧。
|
⛔ merge queue 构建失败 — 先分诊,再决定要不要重排队列构建 41406611368 红了。队列跑的是全量套件(PR 侧 CI 只跑 affected 子集), 分类: 失败的 job(日志抽取,best effort):
跨 PR 相同签名(24h,按失败测试文件聚合):
历史信号:
分诊清单:
Generated by Claude Code · merge-queue-triage workflow (#4859) |
|
domain:server#5 · os-steve · session_01ADHkmQKwKFCp1m6Pb6Q8c1 Queue kick · triage and one re-queue · 2026-11-02T08:14ZThe merge queue removed this PR at 2026-11-02T07:47:34Z (build run 41406611368). Seat 5 holds #28919 now (claim on the card); the ACCEPT 6570671797 stands on head
|
domain:server#5 · os-project-manager · session_01FEkQ5oc56xChD6Wrc4cGSt
Requested by Leehom · project thread
Fixes #28919
Clause-②: no
Metadata-protocol: none
维护者速读
sys_notification_template)按收件人 locale 取行时,在en之前多试一级:栈声明的 fallback locale(i18n.fallbackLocale,否则defaultLocale)及其主语言(zh-CN→zh)。en,同一个收件人在同一个栈上两类模板答案不同。en,结果不变。回滚即 revert 本 PR。template-renderer.ts(localeCandidates与declaredFallbackLocale)、messaging-service-plugin.ts(把 i18n 的getFallbackLocale交给 store)、template-declared-fallback.test.ts。pnpm --filter @objectstack/service-messaging exec vitest run src/template-declared-fallback.test.ts,预期 12 个用例全绿。What changes
NotificationTemplateStore's ladder for a named recipient locale is now: the named tag, its primary subtag, the stack's declared fallback and its primary subtag, thenDEFAULT_LOCALE(en). Duplicates are dropped, so a stack declaringenwalks exactly the old ladder.getFallbackLocale, resolved from the service registry at call time, so an i18n service registered afterkernel:readyis seen. Both hops are optional. A missing service, a missing method, an empty or non-tag answer, or a throw leave the rung out, and the store answers as it did before.TEMPLATE_DECLARED_FALLBACK_LOCALE, with theNotificationTemplateStoreWiringtype), declared intemplate-renderer.tsand not re-exported from the package entry. This is the same shape fix(plugin-email): a templated email to a named locale folds it against the template's locales and tries the stack's declared fallback before en-US #28917 used on the email side. The publishedNotificationTemplateStoreOptionsand the class declaration are unchanged. The builtdist/index.d.tsanddist/index.d.ctsdiffer frommainonly in the store's docblock text.resolveBundleLocalefold. The store reads rows onefindOneat a time and holds no locale list, so it cannot fold without a new read. The fallback takes the same two steps as the named tag (tagThenPrimary), and no third copy of the BCP-47 ladder is added.enrung, matching the email side, where a no-locale call is unchanged.notification-template.object.ts(the locale field) now gives the new two-resolver reading: the declared-fallback rung is shared, and the fold is not. The email-channel comment names the new rung.Why
After #28917 (#28880), a templated email to a recipient whose locale has no row tries the declared fallback before
en-US. Asys_notification_templaterender for the same recipient went straight toen. The two template families answered the same recipient on the same stack differently.Measurement (ruling 3). No shipped stack declares a non-
enfallback.examples/app-crm,app-showcaseandapp-tododeclarefallbackLocale: 'en',app-multi-packagedeclares no i18n block, and hotcrm'ssrc/salesdeclares'en'. So for every shipped stack the ladder is unchanged. A stack that declaresdefaultLocale: 'zh-CN'and nofallbackLocalegetszh-CNas its fallback throughos serve'sfallbackLocale || defaultLocale || 'en', and that stack's ladder changes. The plugin already reads the i18n service from its context (getDefaultTemplateLocale), so the store reaches it without a new published member.Tests
src/template-declared-fallback.test.ts(new, 12 cases):en. The fallback folds to its primary subtag. The recipient's primary subtag still wins over the fallback. The ladder landsenwhen nothing matches. A changed answer is seen on the next resolve. Four ways of having no fallback (no reader,undefined, blank, throws) give today's ladder['fr-FR','fr','en']. A no-locale call readsenalone.update/deletethroughassertEngineUpdateDispatch/assertEngineDeleteDispatch, and its three rows are recorded inscripts/engine-double-contract.pinned.json(--write: 0 added or grown elsewhere, 0 lost).MessagingServicePlugin, the mounted email channel renders thezh-CNrow for afr-FRrecipient when an i18n service withgetFallbackLocale: 'zh-CN'is registered AFTERkernel:ready, and renders theenrow on a host with no i18n service.Red first on main (5 red / 7 green)
Test file only, implementation absent: the five fallback cases fail (
picks the declared fallback before en…,folds… primary subtag,lands en when neither…,reads… at each resolve, the composition case). The no-fallback, subtag-wins and no-locale cases pass, as today's ladder already answers them.Ablation, one per rung (each through scripts/ablation-replace.mjs, restored to a byte-identical HEAD)
Tests import the source by relative path, so no
dist/rebuild is in the path.tagThenPrimary(declaredFallback): 5 failed.push(declaredFallback)): 3 failed (folds…,lands en…,reads… at each resolve).the recipient's primary subtag still wins.a reader that throws). The first attempt was refused by the tool as a no-op (the replacement was a substring of the anchor) and ran nothing. The rerun used a distinct replacement.Acceptance notes
resolveBundleLocale(see ruling 2 above). Azh-TWfallback over a store holding onlyzh-CNtherefore landszhoren, notzh-CN. The email side folds that case.packages/spec/**andplugin-email.Verification
All readings are on head
1c8f2f69(origin/mainmerged), except the ablation and d.ts readings, which were taken on the implementation commits before the merge.pnpm --filter @objectstack/service-messaging test: exit 0, Test Files 63/63, Tests 771/771.pnpm --filter @objectstack/service-messaging typecheck: exit 0. The new test file is in the package'stsc --listFiles.eslint --no-inline-config packages/services/service-messaging/src: exit 0.dist/index.d.tsanddist/index.d.ctswere built at the base and at the fix. They differ only in theNotificationTemplateStoredocblock text. No type, member or export changed, and the module-private symbol does not appear.node scripts/pm/dispatch-gates.mjs --commands --repo objectstack-ai/objectstack): 71 derived, 71 run, all exit 0.--ranreconciliation: 0 NOT-MEASURED, 0 UNRUN. Prerequisites cleared before the run:check:i18nandcheck:dual-build-cjs-loadsread built output (closure built), andcheck-plugin-teardown-shape --self-testneeds its pinned fixture commit fetched.