From e2708e28c98e11929070d290fc62593ed74e0092 Mon Sep 17 00:00:00 2001 From: Claude Date: Thu, 26 Nov 2026 16:40:36 +0000 Subject: [PATCH 1/2] fix(runtime): the comment and webhook redelivery doors' 501 follows the request's language The comment doors and the webhook redelivery door answered a fixed English 501 NOT_IMPLEMENTED while the own-door bridge's print, personal-view and attachment doors answer in the request's Accept-Language. Their four sentences are now operation-message catalog keys in en, zh-CN, ja-JP and es-ES (English byte-identical), read with the bridge's own locale reader. The bridge's nounKey is required, so no bridge ships an English-only 501, and a plural noun reads a _plural pair: the attachment doors' English now says "are". Co-Authored-By: Claude Claude-Session: https://claude.ai/code/session_01L6bhgUpnvPnJ1hR74pUrVj --- .changeset/37610-own-door-501-locale-rest.md | 14 +++++ packages/runtime/src/domains/attachments.ts | 2 + packages/runtime/src/domains/comments.test.ts | 53 +++++++++++++++++++ packages/runtime/src/domains/comments.ts | 10 ++-- .../src/domains/own-door-bridge.test.ts | 40 ++++---------- .../runtime/src/domains/own-door-bridge.ts | 38 +++++++------ .../src/domains/webhooks-redeliver.test.ts | 51 ++++++++++++++++++ packages/runtime/src/domains/webhooks.ts | 11 ++-- packages/spec/src/system/operation-message.ts | 53 +++++++++++++++++-- 9 files changed, 214 insertions(+), 58 deletions(-) create mode 100644 .changeset/37610-own-door-501-locale-rest.md diff --git a/.changeset/37610-own-door-501-locale-rest.md b/.changeset/37610-own-door-501-locale-rest.md new file mode 100644 index 00000000000..d5778b3a70b --- /dev/null +++ b/.changeset/37610-own-door-501-locale-rest.md @@ -0,0 +1,14 @@ +--- +'@objectstack/spec': patch +'@objectstack/runtime': patch +--- + +Clause-②: yes (widening) +Metadata-protocol: none +Skills-docs: none (no page under `skills/**` names these doors' `501` sentences) + +The comment doors and the webhook redelivery door now answer their `501 NOT_IMPLEMENTED` in the request's language, as the print, personal-view and attachment doors do. On a kernel with no `comments` or `webhooks` service, or with one that lacks `handleCommentDoor` / `handleRedeliver`, a `zh-CN`, `ja-JP` or `es-ES` request read the sentence in English. The operation-message catalog (`BUILTIN_OPERATION_MESSAGES`, `@objectstack/spec/system`) gains `comment_doors_service_unregistered`, `comment_doors_member_missing`, `webhook_redeliver_service_unregistered` and `webhook_redeliver_member_missing` in `en`, `zh-CN`, `ja-JP` and `es-ES`; their English is the sentence each door answered before, byte for byte. Code and status do not change, and no `userMessage` is added. + +**The English moved for one door.** The attachment removal and rename doors' `501` now reads "The attachment removal and rename doors **are** not available: …" (it read "is"). The catalog gains `own_door_service_unregistered_plural` and `own_door_member_missing_plural` in the four locales, read by a bridge whose noun is plural; the `es-ES` noun of `own_door_attachment_mutate` becomes plural to match ("Los puntos de acceso para eliminar y renombrar adjuntos no están disponibles: …"). The `zh-CN` and `ja-JP` sentences do not change. + +In `@objectstack/runtime` (internal), the own-door bridge's `nounKey` is required, so no bridge can ship a `501` that stays English under another language. diff --git a/packages/runtime/src/domains/attachments.ts b/packages/runtime/src/domains/attachments.ts index 570de5b9dc7..b99876e42e8 100644 --- a/packages/runtime/src/domains/attachments.ts +++ b/packages/runtime/src/domains/attachments.ts @@ -36,6 +36,8 @@ export const ATTACHMENTS_BRIDGE: OwnDoorBridge = Object.freeze({ noun: 'the attachment removal and rename doors', // [#37352] The catalog key of `noun`: the bridge's `501` follows the request's language. nounKey: 'own_door_attachment_mutate', + // [#37610] Two doors: the `501` says "are". + nounPlural: true, tag: 'attachments', }); diff --git a/packages/runtime/src/domains/comments.test.ts b/packages/runtime/src/domains/comments.test.ts index b0ce5012a0a..ce7eedb466c 100644 --- a/packages/runtime/src/domains/comments.test.ts +++ b/packages/runtime/src/domains/comments.test.ts @@ -275,3 +275,56 @@ describe('[#36469] no preamble-gate exemption — the credential is the session, expect(comments.handleCommentDoor).not.toHaveBeenCalled(); }); }); + +// [#37610] The comment doors' two `501` sentences are the operation-message +// catalog's, in the request's top `Accept-Language` tag, as the own-door +// bridge answers its doors' own. The English is byte for byte the sentence the +// door answered before, the code and status are unchanged, and no +// `userMessage` is added. +describe('[#37610] the comment doors\' 501 follows the request\'s language', () => { + const SENTENCES = { + unregistered: { + en: 'The comment doors are not available: no comments service is registered. @objectstack/plugin-audit registers it; compose AuditPlugin on this kernel.', + 'zh-CN': '评论接口不可用:未注册 comments 服务。该服务由 @objectstack/plugin-audit 注册;请在此内核上组合 AuditPlugin。', + 'ja-JP': 'コメントエンドポイントは利用できません。comments サービスが登録されていません。このサービスは @objectstack/plugin-audit が登録します。このカーネルに AuditPlugin を組み込んでください。', + 'es-ES': 'Los puntos de acceso de comentarios no están disponibles: no hay ningún servicio comments registrado. Lo registra @objectstack/plugin-audit; componga AuditPlugin en este kernel.', + }, + memberMissing: { + en: 'The comment doors are not available: the registered comments service does not implement handleCommentDoor.', + 'zh-CN': '评论接口不可用:已注册的 comments 服务未实现 handleCommentDoor。', + 'ja-JP': 'コメントエンドポイントは利用できません。登録されている comments サービスは handleCommentDoor を実装していません。', + 'es-ES': 'Los puntos de acceso de comentarios no están disponibles: el servicio comments registrado no implementa handleCommentDoor.', + }, + }; + const HEADERS: Record>> = { + en: [{ 'accept-language': 'en-US,en;q=0.9' }, {}], + 'zh-CN': [{ 'accept-language': 'zh-CN,zh;q=0.9,en;q=0.8' }], + 'ja-JP': [{ 'accept-language': 'ja-JP,ja;q=0.9' }], + 'es-ES': [{ 'accept-language': 'es-ES,es;q=0.9' }], + }; + + for (const site of [ + { name: 'no comments slot on the kernel', services: {} as Record, sentences: SENTENCES.unregistered }, + { name: 'a comments service without handleCommentDoor', services: { comments: { somethingElse: vi.fn() } }, sentences: SENTENCES.memberMissing }, + ]) { + it(`${site.name}: 501 NOT_IMPLEMENTED in en (and with no header), zh-CN, ja-JP and es-ES, on every door`, async () => { + for (const [method, path, body] of DOORS) { + for (const [locale, list] of Object.entries(HEADERS) as Array<[keyof typeof HEADERS, Array>]>) { + for (const headers of list) { + const { dispatcher } = makeDispatcher(site.services); + const request = new Request(`${ORIGIN}/api/v1${path}`, { + method, + headers: { ...JSON_HEADERS, ...headers }, + ...(body === undefined ? {} : { body: JSON.stringify(body) }), + }); + const label = `${method} ${path} ${JSON.stringify(headers)}`; + const result = await dispatcher.dispatch(method, path, {}, {}, ctx(request)); + expect(envelope(result), label).toEqual({ status: 501, code: 'NOT_IMPLEMENTED' }); + expect(result.response?.body?.error?.message, label).toBe(site.sentences[locale]); + expect(result.response?.body?.error?.userMessage, label).toBeUndefined(); + } + } + } + }); + } +}); diff --git a/packages/runtime/src/domains/comments.ts b/packages/runtime/src/domains/comments.ts index ac54dfd29a8..9a19b7cbe08 100644 --- a/packages/runtime/src/domains/comments.ts +++ b/packages/runtime/src/domains/comments.ts @@ -74,9 +74,11 @@ */ import { INTERNAL_ERROR_MESSAGE } from '@objectstack/types'; +import { operationUserMessage } from '@objectstack/core'; import type { ICommentDoorsService } from '@objectstack/spec/contracts'; import type { HttpProtocolContext, HttpDispatcherResult } from '../http-dispatcher.js'; import type { DomainHandlerDeps, DomainRequest, DomainRoute } from '../domain-handler-registry.js'; +import { requestLocaleOf } from './own-door-bridge.js'; /** The prefix the domain claims (a segment claim, narrowed by the handler). */ export const COMMENTS_DOMAIN_PREFIX = '/comments'; @@ -158,12 +160,13 @@ export async function handleCommentsRequest( const service = await deps.resolveService(context, COMMENTS_SLOT, context.environmentId) as Pick | undefined; + // [#37610] The `501` is the operation-message catalog's, in the request's + // top `Accept-Language` tag, as the own-door bridge answers its own. if (!service) { return { handled: true, response: deps.error( - 'The comment doors are not available: no comments service is registered. ' - + '@objectstack/plugin-audit registers it; compose AuditPlugin on this kernel.', + operationUserMessage('comment_doors_service_unregistered', { locale: requestLocaleOf(context) }), 501, ), }; @@ -172,8 +175,7 @@ export async function handleCommentsRequest( return { handled: true, response: deps.error( - 'The comment doors are not available: the registered comments service ' - + 'does not implement handleCommentDoor.', + operationUserMessage('comment_doors_member_missing', { locale: requestLocaleOf(context) }), 501, ), }; diff --git a/packages/runtime/src/domains/own-door-bridge.test.ts b/packages/runtime/src/domains/own-door-bridge.test.ts index 3afcf8fecb5..9ad1d18f0f9 100644 --- a/packages/runtime/src/domains/own-door-bridge.test.ts +++ b/packages/runtime/src/domains/own-door-bridge.test.ts @@ -41,7 +41,6 @@ import '@objectstack/metadata'; import { HttpDispatcher } from '../http-dispatcher.js'; import type { HttpProtocolContext, KernelResolver } from '../http-dispatcher.js'; import { BUILTIN_OPERATION_MESSAGES } from '@objectstack/spec/system'; -import { handleOwnDoorBridgeRequest } from './own-door-bridge.js'; import { PERSONAL_VIEWS_BRIDGE } from './personal-views.js'; import { ATTACHMENTS_BRIDGE } from './attachments.js'; import { PRINT_BRIDGE } from './print.js'; @@ -377,7 +376,7 @@ describe.each(FAMILIES)('[#36506] $prefix forwards its doors to the $slot member // [#37273] The bridge's two `501` sentences are the operation-message // catalog's, in the request's top `Accept-Language` tag, for a bridge that // names its noun's key (the print door). Code and status are unchanged, no -// `userMessage` is added, and a bridge that names no noun key keeps English. +// `userMessage` is added. describe('[#37273] the print door\'s 501 follows the request\'s language', () => { const [method, path, body] = ['POST', '/print/records', { app: 'sales', object: 'invoice', recordId: 'inv_1', page: 'invoice_document' }] as const; const withHeaders = (headers: Record) => { @@ -416,27 +415,8 @@ describe('[#37273] the print door\'s 501 follows the request\'s language', () => } }); - it('a bridge that names no noun key keeps its English sentence under zh-CN: never half translated', async () => { - // [#37352] Every shipped bridge names its noun key now, so the control is - // a shipped bridge with the key taken off, handed to the bridge directly. - const deps = { - routeNotFound: vi.fn(), - getRequestKernelService: async () => undefined, - error: (message: string, status: number) => ({ status, body: { error: { code: 'NOT_IMPLEMENTED', message } } }), - } as any; - const request = new Request(`${ORIGIN}/api/v1/personal-views/pv_1`, { method: 'DELETE', headers: { ...JSON_HEADERS, 'accept-language': 'zh-CN' } }); - const result = await handleOwnDoorBridgeRequest( - deps, - { ...PERSONAL_VIEWS_BRIDGE, nounKey: undefined }, - { method: 'DELETE', path: '/personal-views/pv_1', body: {}, query: {} }, - ctx(request), - ); - expect(envelope(result)).toEqual({ status: 501, code: 'NOT_IMPLEMENTED' }); - expect(result.response?.body?.error?.message).toBe( - 'The personal view delete door is not available: no personal-views service is registered on this kernel. ' - + '@objectstack/plugin-auth (AuthPlugin) registers it.', - ); - }); + // [#37610] The English-only arm is gone: `nounKey` is required, so no + // bridge can ship a `501` that stays English under another language. }); // [#37352] The personal-view and attachment doors sit on the same bridge as the @@ -469,16 +449,16 @@ describe('[#37352] the personal-view and attachment doors\' 501s follow the requ ...AT, requests: [['DELETE', '/attachments/att_1'], ['PATCH', '/attachments/att_1', { file_name: 'renamed.pdf' }]] as Array<[string, string, unknown?]>, unregistered: { - en: 'The attachment removal and rename doors is not available: no file-attachments service is registered on this kernel. @objectstack/service-storage (StorageServicePlugin) registers it.', + en: 'The attachment removal and rename doors are not available: no file-attachments service is registered on this kernel. @objectstack/service-storage (StorageServicePlugin) registers it.', 'zh-CN': '附件删除和重命名接口不可用:此内核上未注册 file-attachments 服务。该服务由 @objectstack/service-storage (StorageServicePlugin) 注册。', 'ja-JP': '添付ファイルの削除・名前変更エンドポイントは利用できません。このカーネルには file-attachments サービスが登録されていません。このサービスは @objectstack/service-storage (StorageServicePlugin) が登録します。', - 'es-ES': 'El punto de acceso para eliminar y renombrar adjuntos no está disponible: no hay ningún servicio file-attachments registrado en este kernel. Lo registra @objectstack/service-storage (StorageServicePlugin).', + 'es-ES': 'Los puntos de acceso para eliminar y renombrar adjuntos no están disponibles: no hay ningún servicio file-attachments registrado en este kernel. Lo registra @objectstack/service-storage (StorageServicePlugin).', }, memberMissing: { - en: 'The attachment removal and rename doors is not available: the registered file-attachments service does not implement handleAttachmentDoor.', + en: 'The attachment removal and rename doors are not available: the registered file-attachments service does not implement handleAttachmentDoor.', 'zh-CN': '附件删除和重命名接口不可用:已注册的 file-attachments 服务未实现 handleAttachmentDoor。', 'ja-JP': '添付ファイルの削除・名前変更エンドポイントは利用できません。登録されている file-attachments サービスは handleAttachmentDoor を実装していません。', - 'es-ES': 'El punto de acceso para eliminar y renombrar adjuntos no está disponible: el servicio file-attachments registrado no implementa handleAttachmentDoor.', + 'es-ES': 'Los puntos de acceso para eliminar y renombrar adjuntos no están disponibles: el servicio file-attachments registrado no implementa handleAttachmentDoor.', }, }, ]; @@ -521,8 +501,8 @@ describe('[#37352] the personal-view and attachment doors\' 501s follow the requ } it('the English the catalog keys carry is each bridge\'s noun, byte for byte', () => { - expect(BUILTIN_OPERATION_MESSAGES.en[PERSONAL_VIEWS_BRIDGE.nounKey!]).toBe(PERSONAL_VIEWS_BRIDGE.noun); - expect(BUILTIN_OPERATION_MESSAGES.en[ATTACHMENTS_BRIDGE.nounKey!]).toBe(ATTACHMENTS_BRIDGE.noun); - expect(BUILTIN_OPERATION_MESSAGES.en[PRINT_BRIDGE.nounKey!]).toBe(PRINT_BRIDGE.noun); + expect(BUILTIN_OPERATION_MESSAGES.en[PERSONAL_VIEWS_BRIDGE.nounKey]).toBe(PERSONAL_VIEWS_BRIDGE.noun); + expect(BUILTIN_OPERATION_MESSAGES.en[ATTACHMENTS_BRIDGE.nounKey]).toBe(ATTACHMENTS_BRIDGE.noun); + expect(BUILTIN_OPERATION_MESSAGES.en[PRINT_BRIDGE.nounKey]).toBe(PRINT_BRIDGE.noun); }); }); diff --git a/packages/runtime/src/domains/own-door-bridge.ts b/packages/runtime/src/domains/own-door-bridge.ts index 0b5835a501b..ef952cd4edd 100644 --- a/packages/runtime/src/domains/own-door-bridge.ts +++ b/packages/runtime/src/domains/own-door-bridge.ts @@ -69,10 +69,10 @@ * own for its 5xx). The bridge holds no `ExecutionContext` and no `i18n` * service, so the header is the only source and no `errors.own_door_*` * override is consulted. The door's noun is a catalog key too - * ({@link OwnDoorBridge.nounKey}); a bridge that names none keeps its English - * sentence whatever the language, so a sentence is never half translated. - * Only the language moves: the English is byte-identical, the code and the - * status are unchanged, and no `userMessage` is added. The slot, member and + * ({@link OwnDoorBridge.nounKey}), required so no bridge ships an English-only + * `501`; a plural noun ({@link OwnDoorBridge.nounPlural}) reads the `_plural` + * pair of sentences, so the English verb agrees. Only the language moves: the + * code and the status are unchanged, and no `userMessage` is added. The slot, member and * package names are identifiers and stay as written. */ @@ -105,9 +105,14 @@ export interface OwnDoorBridge { /** * [#37273] The operation-message catalog key of {@link noun} (its English * text is `noun`'s, byte for byte), which puts the bridge's `501` in the - * request's language. Absent, the `501` stays English. + * request's language. Required (#37610): a bridge cannot ship English-only. */ - readonly nounKey?: string; + readonly nounKey: string; + /** + * [#37610] {@link noun} is plural (`the … doors`): the `501` reads the + * catalog's `_plural` sentences, so the English says "are". + */ + readonly nounPlural?: true; /** The log tag, e.g. `personal-views`. */ readonly tag: string; } @@ -231,24 +236,25 @@ export async function handleOwnDoorBridgeRequest( } } -/** - * A `501` sentence of the catalog, in the request's top `Accept-Language` tag - * when the bridge names its noun's key, in English otherwise (the noun would - * stay English, and a sentence is never half translated). - */ +/** A `501` sentence of the catalog, in the request's top `Accept-Language` tag. */ function notImplementedSentence( bridge: OwnDoorBridge, context: HttpProtocolContext, messageKey: 'own_door_service_unregistered' | 'own_door_member_missing', params: Record, ): string { - const caller = bridge.nounKey !== undefined ? { locale: requestLocaleOf(context) } : undefined; - const noun = bridge.nounKey !== undefined ? operationUserMessage(bridge.nounKey, caller) : bridge.noun; - return operationUserMessage(messageKey, caller, { door: capitalize(noun), slot: bridge.slot, ...params }); + const caller = { locale: requestLocaleOf(context) }; + const noun = operationUserMessage(bridge.nounKey, caller); + const key = bridge.nounPlural ? `${messageKey}_plural` : messageKey; + return operationUserMessage(key, caller, { door: capitalize(noun), slot: bridge.slot, ...params }); } -/** The request's top `Accept-Language` tag, from a fetch `Request` or a plain header record. */ -function requestLocaleOf(context: HttpProtocolContext): string | undefined { +/** + * The request's top `Accept-Language` tag, from a fetch `Request` or a plain + * header record: the language of an own door's `501` (#37610: the comment and + * webhook redelivery doors read it too). + */ +export function requestLocaleOf(context: HttpProtocolContext): string | undefined { const headers = (context.request as { headers?: unknown } | undefined)?.headers as | { get?: (name: string) => string | null } | Record diff --git a/packages/runtime/src/domains/webhooks-redeliver.test.ts b/packages/runtime/src/domains/webhooks-redeliver.test.ts index a55f739a6e1..2893cac8375 100644 --- a/packages/runtime/src/domains/webhooks-redeliver.test.ts +++ b/packages/runtime/src/domains/webhooks-redeliver.test.ts @@ -320,3 +320,54 @@ describe('[#22755] no preamble-gate exemption — the credential is the session, expect(webhooks.handleRedeliver).not.toHaveBeenCalled(); }); }); + +// [#37610] The redelivery door's two `501` sentences are the operation-message +// catalog's, in the request's top `Accept-Language` tag, as the own-door +// bridge answers its doors' own. The English is byte for byte the sentence the +// door answered before, the code and status are unchanged, and no +// `userMessage` is added. +describe('[#37610] the redelivery door\'s 501 follows the request\'s language', () => { + const SENTENCES = { + unregistered: { + en: 'Webhook redelivery is not available: no webhooks service is registered. @objectstack/plugin-webhooks registers it once its redelivery veto is installed, which needs the data engine and @objectstack/service-messaging; the boot log names the one that is missing.', + 'zh-CN': 'Webhook 重新投递不可用:未注册 webhooks 服务。@objectstack/plugin-webhooks 在安装其重新投递否决器后注册该服务,这需要数据引擎和 @objectstack/service-messaging;启动日志会指出缺少的是哪一个。', + 'ja-JP': 'Webhook の再配信は利用できません。webhooks サービスが登録されていません。@objectstack/plugin-webhooks は再配信の拒否フックがインストールされると登録します。それにはデータエンジンと @objectstack/service-messaging が必要です。不足しているものは起動ログに示されます。', + 'es-ES': 'El reenvío de webhooks no está disponible: no hay ningún servicio webhooks registrado. @objectstack/plugin-webhooks lo registra una vez instalado su veto de reenvío, que necesita el motor de datos y @objectstack/service-messaging; el registro de arranque indica cuál falta.', + }, + memberMissing: { + en: 'Webhook redelivery is not available: the registered webhooks service does not implement handleRedeliver.', + 'zh-CN': 'Webhook 重新投递不可用:已注册的 webhooks 服务未实现 handleRedeliver。', + 'ja-JP': 'Webhook の再配信は利用できません。登録されている webhooks サービスは handleRedeliver を実装していません。', + 'es-ES': 'El reenvío de webhooks no está disponible: el servicio webhooks registrado no implementa handleRedeliver.', + }, + }; + const HEADERS: Record>> = { + en: [{ 'accept-language': 'en-US,en;q=0.9' }, {}], + 'zh-CN': [{ 'accept-language': 'zh-CN,zh;q=0.9,en;q=0.8' }], + 'ja-JP': [{ 'accept-language': 'ja-JP,ja;q=0.9' }], + 'es-ES': [{ 'accept-language': 'es-ES,es;q=0.9' }], + }; + + for (const site of [ + { name: 'no webhooks slot on the kernel', services: {} as Record, sentences: SENTENCES.unregistered }, + { name: 'a webhooks service without handleRedeliver', services: { webhooks: { somethingElse: vi.fn() } }, sentences: SENTENCES.memberMissing }, + ]) { + it(`${site.name}: 501 NOT_IMPLEMENTED in en (and with no header), zh-CN, ja-JP and es-ES`, async () => { + for (const [locale, list] of Object.entries(HEADERS) as Array<[keyof typeof HEADERS, Array>]>) { + for (const headers of list) { + const { dispatcher } = makeDispatcher(site.services); + const request = new Request(`${ORIGIN}/api/v1${REDELIVER}`, { + method: 'POST', + headers: { ...JSON_HEADERS, ...headers }, + body: JSON.stringify({ deliveryId: 'del_1' }), + }); + const label = JSON.stringify(headers); + const result = await dispatcher.dispatch('POST', REDELIVER, {}, {}, ctx(request)); + expect(envelope(result), label).toEqual({ status: 501, code: 'NOT_IMPLEMENTED' }); + expect(result.response?.body?.error?.message, label).toBe(site.sentences[locale]); + expect(result.response?.body?.error?.userMessage, label).toBeUndefined(); + } + } + }); + } +}); diff --git a/packages/runtime/src/domains/webhooks.ts b/packages/runtime/src/domains/webhooks.ts index 00a8b3d4a06..a33c00fb3e2 100644 --- a/packages/runtime/src/domains/webhooks.ts +++ b/packages/runtime/src/domains/webhooks.ts @@ -78,9 +78,11 @@ */ import { INTERNAL_ERROR_MESSAGE } from '@objectstack/types'; +import { operationUserMessage } from '@objectstack/core'; import type { IWebhookService } from '@objectstack/spec/contracts'; import type { HttpProtocolContext, HttpDispatcherResult } from '../http-dispatcher.js'; import type { DomainHandlerDeps, DomainRoute } from '../domain-handler-registry.js'; +import { requestLocaleOf } from './own-door-bridge.js'; /** * The one path this domain claims — exactly, with no sub-paths: the redeliver @@ -113,13 +115,13 @@ export async function handleWebhooksRedeliverRequest( ): Promise { const service = await deps.resolveService(context, WEBHOOKS_SLOT, context.environmentId) as Pick | undefined; + // [#37610] The `501` is the operation-message catalog's, in the request's + // top `Accept-Language` tag, as the own-door bridge answers its own. if (!service) { return { handled: true, response: deps.error( - 'Webhook redelivery is not available: no webhooks service is registered. ' - + '@objectstack/plugin-webhooks registers it once its redelivery veto is installed, which needs ' - + 'the data engine and @objectstack/service-messaging; the boot log names the one that is missing.', + operationUserMessage('webhook_redeliver_service_unregistered', { locale: requestLocaleOf(context) }), 501, ), }; @@ -128,8 +130,7 @@ export async function handleWebhooksRedeliverRequest( return { handled: true, response: deps.error( - 'Webhook redelivery is not available: the registered webhooks service ' - + 'does not implement handleRedeliver.', + operationUserMessage('webhook_redeliver_member_missing', { locale: requestLocaleOf(context) }), 501, ), }; diff --git a/packages/spec/src/system/operation-message.ts b/packages/spec/src/system/operation-message.ts index 4e5a830898a..fae0b73db49 100644 --- a/packages/spec/src/system/operation-message.ts +++ b/packages/spec/src/system/operation-message.ts @@ -366,8 +366,14 @@ export function operationMessageTranslationKey(messageKey: string): string { * `{{member}}` are the slot, package and member names, never translated. The * bridge reads the request's top `Accept-Language` tag, as the print door * does, and holds no `i18n` service either, so no `errors.own_door_*` - * override is consulted. A bridge that names no noun key keeps its English - * sentence whatever the request's language. + * override is consulted. Every bridge names its noun key. A bridge whose noun + * is plural (`own_door_attachment_mutate`) reads the `_plural` pair, so the + * English verb agrees. + * + * The `comment_doors_*` and `webhook_redeliver_*` keys are the same `501` on + * the comment doors (`comments.ts`) and the webhook redelivery door + * (`webhooks.ts`), which are not own-door bridges: each sentence is whole, + * with its slot, member and package names written in, never translated. */ export const BUILTIN_OPERATION_MESSAGES: Record> = { en: { @@ -445,6 +451,17 @@ export const BUILTIN_OPERATION_MESSAGES: Record> own_door_print: 'the print door', own_door_personal_view_delete: 'the personal view delete door', own_door_attachment_mutate: 'the attachment removal and rename doors', + own_door_service_unregistered_plural: + '{{door}} are not available: no {{slot}} service is registered on this kernel. {{producer}} registers it.', + own_door_member_missing_plural: '{{door}} are not available: the registered {{slot}} service does not implement {{member}}.', + comment_doors_service_unregistered: + 'The comment doors are not available: no comments service is registered. @objectstack/plugin-audit registers it; compose AuditPlugin on this kernel.', + comment_doors_member_missing: + 'The comment doors are not available: the registered comments service does not implement handleCommentDoor.', + webhook_redeliver_service_unregistered: + 'Webhook redelivery is not available: no webhooks service is registered. @objectstack/plugin-webhooks registers it once its redelivery veto is installed, which needs the data engine and @objectstack/service-messaging; the boot log names the one that is missing.', + webhook_redeliver_member_missing: + 'Webhook redelivery is not available: the registered webhooks service does not implement handleRedeliver.', }, 'zh-CN': { permission_denied: '您没有执行此操作的权限,如需访问请联系管理员。', @@ -497,6 +514,14 @@ export const BUILTIN_OPERATION_MESSAGES: Record> own_door_print: '打印接口', own_door_personal_view_delete: '个人视图删除接口', own_door_attachment_mutate: '附件删除和重命名接口', + own_door_service_unregistered_plural: '{{door}}不可用:此内核上未注册 {{slot}} 服务。该服务由 {{producer}} 注册。', + own_door_member_missing_plural: '{{door}}不可用:已注册的 {{slot}} 服务未实现 {{member}}。', + comment_doors_service_unregistered: + '评论接口不可用:未注册 comments 服务。该服务由 @objectstack/plugin-audit 注册;请在此内核上组合 AuditPlugin。', + comment_doors_member_missing: '评论接口不可用:已注册的 comments 服务未实现 handleCommentDoor。', + webhook_redeliver_service_unregistered: + 'Webhook 重新投递不可用:未注册 webhooks 服务。@objectstack/plugin-webhooks 在安装其重新投递否决器后注册该服务,这需要数据引擎和 @objectstack/service-messaging;启动日志会指出缺少的是哪一个。', + webhook_redeliver_member_missing: 'Webhook 重新投递不可用:已注册的 webhooks 服务未实现 handleRedeliver。', }, 'ja-JP': { permission_denied: 'この操作を実行する権限がありません。アクセスが必要な場合は管理者にお問い合わせください。', @@ -568,6 +593,17 @@ export const BUILTIN_OPERATION_MESSAGES: Record> own_door_print: '印刷エンドポイント', own_door_personal_view_delete: '個人ビュー削除エンドポイント', own_door_attachment_mutate: '添付ファイルの削除・名前変更エンドポイント', + own_door_service_unregistered_plural: + '{{door}}は利用できません。このカーネルには {{slot}} サービスが登録されていません。このサービスは {{producer}} が登録します。', + own_door_member_missing_plural: '{{door}}は利用できません。登録されている {{slot}} サービスは {{member}} を実装していません。', + comment_doors_service_unregistered: + 'コメントエンドポイントは利用できません。comments サービスが登録されていません。このサービスは @objectstack/plugin-audit が登録します。このカーネルに AuditPlugin を組み込んでください。', + comment_doors_member_missing: + 'コメントエンドポイントは利用できません。登録されている comments サービスは handleCommentDoor を実装していません。', + webhook_redeliver_service_unregistered: + 'Webhook の再配信は利用できません。webhooks サービスが登録されていません。@objectstack/plugin-webhooks は再配信の拒否フックがインストールされると登録します。それにはデータエンジンと @objectstack/service-messaging が必要です。不足しているものは起動ログに示されます。', + webhook_redeliver_member_missing: + 'Webhook の再配信は利用できません。登録されている webhooks サービスは handleRedeliver を実装していません。', }, 'es-ES': { permission_denied: @@ -643,7 +679,18 @@ export const BUILTIN_OPERATION_MESSAGES: Record> own_door_member_missing: '{{door}} no está disponible: el servicio {{slot}} registrado no implementa {{member}}.', own_door_print: 'el punto de acceso de impresión', own_door_personal_view_delete: 'el punto de acceso para eliminar vistas personales', - own_door_attachment_mutate: 'el punto de acceso para eliminar y renombrar adjuntos', + own_door_attachment_mutate: 'los puntos de acceso para eliminar y renombrar adjuntos', + own_door_service_unregistered_plural: + '{{door}} no están disponibles: no hay ningún servicio {{slot}} registrado en este kernel. Lo registra {{producer}}.', + own_door_member_missing_plural: '{{door}} no están disponibles: el servicio {{slot}} registrado no implementa {{member}}.', + comment_doors_service_unregistered: + 'Los puntos de acceso de comentarios no están disponibles: no hay ningún servicio comments registrado. Lo registra @objectstack/plugin-audit; componga AuditPlugin en este kernel.', + comment_doors_member_missing: + 'Los puntos de acceso de comentarios no están disponibles: el servicio comments registrado no implementa handleCommentDoor.', + webhook_redeliver_service_unregistered: + 'El reenvío de webhooks no está disponible: no hay ningún servicio webhooks registrado. @objectstack/plugin-webhooks lo registra una vez instalado su veto de reenvío, que necesita el motor de datos y @objectstack/service-messaging; el registro de arranque indica cuál falta.', + webhook_redeliver_member_missing: + 'El reenvío de webhooks no está disponible: el servicio webhooks registrado no implementa handleRedeliver.', }, }; From 4c2a96e4634eff78ff10613fec02d8c4a57543ce Mon Sep 17 00:00:00 2001 From: Claude Date: Thu, 26 Nov 2026 16:54:46 +0000 Subject: [PATCH 2/2] test(runtime): pay the metadata load during collection in the redelivery test check:test-source-alias: the edited test reaches standalone-stack.ts's dynamic @objectstack/metadata import, so it imports it at module top, as comments.test.ts does. Co-Authored-By: Claude Claude-Session: https://claude.ai/code/session_01L6bhgUpnvPnJ1hR74pUrVj --- packages/runtime/src/domains/webhooks-redeliver.test.ts | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/packages/runtime/src/domains/webhooks-redeliver.test.ts b/packages/runtime/src/domains/webhooks-redeliver.test.ts index 2893cac8375..7051d38b75f 100644 --- a/packages/runtime/src/domains/webhooks-redeliver.test.ts +++ b/packages/runtime/src/domains/webhooks-redeliver.test.ts @@ -39,6 +39,10 @@ */ import { describe, it, expect, vi } from 'vitest'; +// Paid during collection, not inside a case's clock: the dispatcher reaches +// `standalone-stack.ts`, whose dynamic `@objectstack/metadata` import would +// otherwise load inside the first case that gets that far (check:test-source-alias). +import '@objectstack/metadata'; import { HttpDispatcher } from '../http-dispatcher.js'; import type { HttpProtocolContext, KernelResolver } from '../http-dispatcher.js';