From bcf922153e6d00f00cc5dfb8878f0f07a675f382 Mon Sep 17 00:00:00 2001 From: Claude Date: Fri, 27 Nov 2026 04:28:23 +0000 Subject: [PATCH 1/2] =?UTF-8?q?fix(runtime):=20a=20501=20answered=20in=20t?= =?UTF-8?q?he=20request's=20language=20says=20it=20varies=20by=20Accept-La?= =?UTF-8?q?nguage,=20and=20the=20inbound=20automation=20hooks'=20Japanese?= =?UTF-8?q?=20501=20says=20=E8=87=AA=E5=8B=95=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The localized 501s (the own-door bridge, the comment doors, webhook redelivery, the approval action-page door, the inbound automation hooks) now answer through one helper that adds Vary: Accept-Language: a 501 is cacheable by default, so a shared cache could otherwise serve one reader's language to the next. Also: the two ja-JP automation_hooks sentences say 受信自動化フック, the platform's Japanese term; the catalog jsdoc states how a request's tag is matched (es-MX → es-ES, zh/zh-TW → zh-CN, ja → ja-JP); requestLocaleOf's jsdoc names its four reader families; the bridge walk also finds a module that calls handleOwnDoorBridgeRequest directly, and every bridge noun must end in door/doors so its plurality is read off the word. Co-Authored-By: Claude Claude-Session: https://claude.ai/code/session_01L6bhgUpnvPnJ1hR74pUrVj --- .changeset/37737-own-door-501-ja-vary.md | 13 +++++ .../runtime/src/domains/approvals-act.test.ts | 2 + packages/runtime/src/domains/approvals.ts | 19 +------ .../src/domains/automation-hooks.test.ts | 6 +- .../runtime/src/domains/automation-hooks.ts | 19 +------ packages/runtime/src/domains/comments.test.ts | 2 + packages/runtime/src/domains/comments.ts | 19 +------ .../src/domains/own-door-bridge.test.ts | 23 ++++++-- .../runtime/src/domains/own-door-bridge.ts | 55 +++++++++++++------ .../src/domains/webhooks-redeliver.test.ts | 2 + packages/runtime/src/domains/webhooks.ts | 19 +------ packages/spec/src/system/operation-message.ts | 14 +++-- 12 files changed, 101 insertions(+), 92 deletions(-) create mode 100644 .changeset/37737-own-door-501-ja-vary.md diff --git a/.changeset/37737-own-door-501-ja-vary.md b/.changeset/37737-own-door-501-ja-vary.md new file mode 100644 index 00000000000..bd305ff91b9 --- /dev/null +++ b/.changeset/37737-own-door-501-ja-vary.md @@ -0,0 +1,13 @@ +--- +'@objectstack/runtime': patch +'@objectstack/spec': patch +--- + +fix(runtime): a 501 answered in the request's language says it varies by Accept-Language, and the inbound automation hooks' Japanese 501 says 自動化 + +Clause-②: no +Metadata-protocol: none + +The `501 NOT_IMPLEMENTED` answers that are localized from the request's `Accept-Language` (the print, personal-view and attachment doors' bridge, the comment doors, the webhook redelivery door, the approval action-page door and the inbound automation hooks) now carry `Vary: Accept-Language`. A `501` is cacheable by default, so a shared cache in front of the API could otherwise hand one reader's language to the next; nothing else about these answers changes. + +The two `ja-JP` sentences of the inbound automation hooks say `受信自動化フック`, the term the platform's Japanese bundles use, instead of `受信オートメーションフック`. The operation-message catalog's doc comments now say how a request's language is matched (`es-MX` reads `es-ES`, `zh` and `zh-TW` read `zh-CN`, `ja` reads `ja-JP`; only a language with no catalog locale answers English). diff --git a/packages/runtime/src/domains/approvals-act.test.ts b/packages/runtime/src/domains/approvals-act.test.ts index eee46e312f1..5a3dbc6b853 100644 --- a/packages/runtime/src/domains/approvals-act.test.ts +++ b/packages/runtime/src/domains/approvals-act.test.ts @@ -370,6 +370,8 @@ describe('[#37662] the action-page door\'s 501 follows the request\'s language', const label = JSON.stringify(headers); const result = await dispatcher.dispatch('GET', ACT, undefined, {}, ctx(request)); expect(envelope(result), label).toEqual({ status: 501, code: 'NOT_IMPLEMENTED' }); + // [#37737] The body is in the request's language, so the answer says it varies by it. + expect(result.response?.headers?.Vary, label).toBe('Accept-Language'); 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/approvals.ts b/packages/runtime/src/domains/approvals.ts index d032ae20813..6fc3889daaa 100644 --- a/packages/runtime/src/domains/approvals.ts +++ b/packages/runtime/src/domains/approvals.ts @@ -65,11 +65,10 @@ */ import { INTERNAL_ERROR_MESSAGE } from '@objectstack/types'; -import { operationUserMessage } from '@objectstack/core'; import type { IApprovalService } 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'; +import { catalogNotImplemented } from './own-door-bridge.js'; /** * The one path this domain claims — exactly, with no sub-paths: the action @@ -114,22 +113,10 @@ export async function handleApprovalsActRequest( // [#37662] 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( - operationUserMessage('approvals_act_service_unregistered', { locale: requestLocaleOf(context) }), - 501, - ), - }; + return catalogNotImplemented(deps, context, 'approvals_act_service_unregistered'); } if (typeof service.handleActionPage !== 'function') { - return { - handled: true, - response: deps.error( - operationUserMessage('approvals_act_member_missing', { locale: requestLocaleOf(context) }), - 501, - ), - }; + return catalogNotImplemented(deps, context, 'approvals_act_member_missing'); } const request = context.request as Request; diff --git a/packages/runtime/src/domains/automation-hooks.test.ts b/packages/runtime/src/domains/automation-hooks.test.ts index f459e72a6c3..c2a6d72f93b 100644 --- a/packages/runtime/src/domains/automation-hooks.test.ts +++ b/packages/runtime/src/domains/automation-hooks.test.ts @@ -936,13 +936,13 @@ describe('[#37662] the inbound hook route\'s 501 follows the request\'s language unregistered: { en: 'Inbound automation hooks are not available: no trigger-api service is registered. The inbound-hook trigger (@objectstack/trigger-api) serves this route through that service; compose it on the environment that owns the flow.', 'zh-CN': '入站自动化钩子不可用:未注册 trigger-api 服务。入站钩子触发器(@objectstack/trigger-api)通过该服务提供此路由;请在拥有该流程的环境上组合它。', - 'ja-JP': '受信オートメーションフックは利用できません。trigger-api サービスが登録されていません。受信フックトリガー(@objectstack/trigger-api)がこのサービスを通じてこのルートを提供します。フローを所有する環境に組み込んでください。', + 'ja-JP': '受信自動化フックは利用できません。trigger-api サービスが登録されていません。受信フックトリガー(@objectstack/trigger-api)がこのサービスを通じてこのルートを提供します。フローを所有する環境に組み込んでください。', 'es-ES': 'Los ganchos de automatización entrantes no están disponibles: no hay ningún servicio trigger-api registrado. El disparador de ganchos entrantes (@objectstack/trigger-api) sirve esta ruta a través de ese servicio; compóngalo en el entorno al que pertenece el flujo.', }, memberMissing: { en: 'Inbound automation hooks are not available: the registered trigger-api service does not implement handleInboundHook.', 'zh-CN': '入站自动化钩子不可用:已注册的 trigger-api 服务未实现 handleInboundHook。', - 'ja-JP': '受信オートメーションフックは利用できません。登録されている trigger-api サービスは handleInboundHook を実装していません。', + 'ja-JP': '受信自動化フックは利用できません。登録されている trigger-api サービスは handleInboundHook を実装していません。', 'es-ES': 'Los ganchos de automatización entrantes no están disponibles: el servicio trigger-api registrado no implementa handleInboundHook.', }, }; @@ -969,6 +969,8 @@ describe('[#37662] the inbound hook route\'s 501 follows the request\'s language const label = JSON.stringify(headers); const result = await dispatcher.dispatch('POST', ROUTE, {}, {}, ctx(request)); expect(envelope(result), label).toEqual({ status: 501, code: 'NOT_IMPLEMENTED' }); + // [#37737] The body is in the request's language, so the answer says it varies by it. + expect(result.response?.headers?.Vary, label).toBe('Accept-Language'); 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/automation-hooks.ts b/packages/runtime/src/domains/automation-hooks.ts index 87e92ae2a43..3fb47dd3692 100644 --- a/packages/runtime/src/domains/automation-hooks.ts +++ b/packages/runtime/src/domains/automation-hooks.ts @@ -91,14 +91,13 @@ import { INTERNAL_ERROR_MESSAGE } from '@objectstack/types'; import { admitInboundHookAddress, inboundHookRefusalResponse, - operationUserMessage, type InboundHookRouteMatch, } from '@objectstack/core'; import { automationAddressRegistryOf } from './automation-address.js'; import type { ITriggerApiService } from '@objectstack/spec/contracts'; import type { HttpProtocolContext, HttpDispatcherResult } from '../http-dispatcher.js'; import type { DomainHandlerDeps } from '../domain-handler-registry.js'; -import { requestLocaleOf } from './own-door-bridge.js'; +import { catalogNotImplemented } from './own-door-bridge.js'; /** The slot the member lives on — the trigger package's own name (ADR-0041 §2). */ const TRIGGER_API_SLOT = 'trigger-api'; @@ -187,22 +186,10 @@ export async function handleInboundHookRequest( // [#37662] 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( - operationUserMessage('automation_hooks_service_unregistered', { locale: requestLocaleOf(context) }), - 501, - ), - }; + return catalogNotImplemented(deps, context, 'automation_hooks_service_unregistered'); } if (typeof service.handleInboundHook !== 'function') { - return { - handled: true, - response: deps.error( - operationUserMessage('automation_hooks_member_missing', { locale: requestLocaleOf(context) }), - 501, - ), - }; + return catalogNotImplemented(deps, context, 'automation_hooks_member_missing'); } const request = context.request as Request; diff --git a/packages/runtime/src/domains/comments.test.ts b/packages/runtime/src/domains/comments.test.ts index ce7eedb466c..e15233a1e6d 100644 --- a/packages/runtime/src/domains/comments.test.ts +++ b/packages/runtime/src/domains/comments.test.ts @@ -320,6 +320,8 @@ describe('[#37610] the comment doors\' 501 follows the request\'s language', () 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' }); + // [#37737] The body is in the request's language, so the answer says it varies by it. + expect(result.response?.headers?.Vary, label).toBe('Accept-Language'); 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 9a19b7cbe08..63341ccdf55 100644 --- a/packages/runtime/src/domains/comments.ts +++ b/packages/runtime/src/domains/comments.ts @@ -74,11 +74,10 @@ */ 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'; +import { catalogNotImplemented } from './own-door-bridge.js'; /** The prefix the domain claims (a segment claim, narrowed by the handler). */ export const COMMENTS_DOMAIN_PREFIX = '/comments'; @@ -163,22 +162,10 @@ export async function handleCommentsRequest( // [#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( - operationUserMessage('comment_doors_service_unregistered', { locale: requestLocaleOf(context) }), - 501, - ), - }; + return catalogNotImplemented(deps, context, 'comment_doors_service_unregistered'); } if (typeof service.handleCommentDoor !== 'function') { - return { - handled: true, - response: deps.error( - operationUserMessage('comment_doors_member_missing', { locale: requestLocaleOf(context) }), - 501, - ), - }; + return catalogNotImplemented(deps, context, 'comment_doors_member_missing'); } const request = context.request as Request; diff --git a/packages/runtime/src/domains/own-door-bridge.test.ts b/packages/runtime/src/domains/own-door-bridge.test.ts index 63bda3beb3b..5b4082ebf00 100644 --- a/packages/runtime/src/domains/own-door-bridge.test.ts +++ b/packages/runtime/src/domains/own-door-bridge.test.ts @@ -406,6 +406,8 @@ describe('[#37273] the print door\'s 501 follows the request\'s language', () => const { dispatcher } = makeDispatcher(site.services); const result = await dispatcher.dispatch(method, path, {}, {}, withHeaders({ 'accept-language': 'zh-CN,zh;q=0.9,en;q=0.8' })); expect(envelope(result)).toEqual({ status: 501, code: 'NOT_IMPLEMENTED' }); + // [#37737] The body is in the request's language, so the answer says it varies by it. + expect(result.response?.headers?.Vary, 'Vary').toBe('Accept-Language'); expect(result.response?.body?.error?.message).toBe(site.zh); expect(result.response?.body?.error?.userMessage).toBeUndefined(); }); @@ -415,6 +417,8 @@ describe('[#37273] the print door\'s 501 follows the request\'s language', () => const { dispatcher } = makeDispatcher(site.services); const result = await dispatcher.dispatch(method, path, {}, {}, withHeaders(headers)); expect(envelope(result), JSON.stringify(headers)).toEqual({ status: 501, code: 'NOT_IMPLEMENTED' }); + // [#37737] The body is in the request's language, so the answer says it varies by it. + expect(result.response?.headers?.Vary, JSON.stringify(headers)).toBe('Accept-Language'); expect(result.response?.body?.error?.message, JSON.stringify(headers)).toBe(site.en); } }); @@ -495,6 +499,8 @@ describe('[#37352] the personal-view and attachment doors\' 501s follow the requ const label = `${request[0]} ${request[1]} ${JSON.stringify(headers)}`; const result = await answer(site.services, request, headers); expect(envelope(result), label).toEqual({ status: 501, code: 'NOT_IMPLEMENTED' }); + // [#37737] The body is in the request's language, so the answer says it varies by it. + expect(result.response?.headers?.Vary, label).toBe('Accept-Language'); expect(result.response?.body?.error?.message, label).toBe(site.sentences[locale]); expect(result.response?.body?.error?.userMessage, label).toBeUndefined(); } @@ -514,8 +520,10 @@ describe('[#37352] the personal-view and attachment doors\' 501s follow the requ /** * [#37662] Every bridge's flags against the catalog, found rather than listed: * each module of this directory that builds a bridge domain - * (`createOwnDoorBridgeDomain(`) is imported and its exported bridges walked, - * so a fourth bridge is held to the same rules the day it lands. + * (`createOwnDoorBridgeDomain(`) or answers through the bridge's handler + * directly (`handleOwnDoorBridgeRequest(`, #37737) is imported and its + * exported bridges walked, so a fourth bridge is held to the same rules the + * day it lands, whichever way it is mounted. */ describe('[#37662] every own-door bridge is tied to the catalog', () => { const isBridge = (value: unknown): value is OwnDoorBridge => @@ -526,7 +534,10 @@ describe('[#37662] every own-door bridge is tied to the catalog', () => { const here = dirname(fileURLToPath(import.meta.url)); const builders = readdirSync(here) .filter((name) => name.endsWith('.ts') && !name.endsWith('.test.ts') && name !== 'own-door-bridge.ts') - .filter((name) => readFileSync(join(here, name), 'utf8').includes('createOwnDoorBridgeDomain(')); + .filter((name) => { + const source = readFileSync(join(here, name), 'utf8'); + return source.includes('createOwnDoorBridgeDomain(') || source.includes('handleOwnDoorBridgeRequest('); + }); it('finds the shipped bridges, each module exporting the bridge it builds', async () => { const found: Array<[string, OwnDoorBridge]> = []; @@ -546,8 +557,12 @@ describe('[#37662] every own-door bridge is tied to the catalog', () => { expect(BUILTIN_OPERATION_MESSAGES[locale][bridge.nounKey], `${exported} ${locale}`).toBeTruthy(); } expect(BUILTIN_OPERATION_MESSAGES.en[bridge.nounKey], exported).toBe(bridge.noun); + // [#37737] The English noun names its door(s) last, so whether it is + // plural is read off the word and never guessed (`the … endpoints` + // would read as plural with no flag to say so). + expect(bridge.noun, exported).toMatch(/\bdoors?$/); // `nounPlural` is set exactly when the English noun is plural (`the … doors`). - expect(bridge.nounPlural === true, `${exported}: '${bridge.noun}'`).toBe(/\bdoors\b/.test(bridge.noun)); + expect(bridge.nounPlural === true, `${exported}: '${bridge.noun}'`).toBe(/\bdoors$/.test(bridge.noun)); // The pair of sentences the bridge reads is in every locale. const suffix = bridge.nounPlural ? '_plural' : ''; for (const key of ['own_door_service_unregistered', 'own_door_member_missing']) { diff --git a/packages/runtime/src/domains/own-door-bridge.ts b/packages/runtime/src/domains/own-door-bridge.ts index 60edffd9cd7..2b3cd90b769 100644 --- a/packages/runtime/src/domains/own-door-bridge.ts +++ b/packages/runtime/src/domains/own-door-bridge.ts @@ -100,7 +100,11 @@ export interface OwnDoorBridge { readonly member: string; /** The package that registers the slot, named in the `501` for an empty slot. */ readonly producer: string; - /** The doors' noun for answers and log lines, e.g. `the personal view door`. */ + /** + * The doors' noun for answers and log lines, e.g. `the personal view door`. + * It ends in `door` or `doors`, which is what says it is plural + * (`nounPlural`), pinned by `own-door-bridge.test.ts`. + */ readonly noun: string; /** * [#37273] The operation-message catalog key of {@link noun} (its English @@ -188,23 +192,11 @@ export async function handleOwnDoorBridgeRequest( service = undefined; } if (!service) { - return { - handled: true, - response: deps.error( - notImplementedSentence(bridge, context, 'own_door_service_unregistered', { producer: bridge.producer }), - 501, - ), - }; + return localizedNotImplemented(deps, notImplementedSentence(bridge, context, 'own_door_service_unregistered', { producer: bridge.producer })); } const member = service[bridge.member]; if (typeof member !== 'function') { - return { - handled: true, - response: deps.error( - notImplementedSentence(bridge, context, 'own_door_member_missing', { member: bridge.member }), - 501, - ), - }; + return localizedNotImplemented(deps, notImplementedSentence(bridge, context, 'own_door_member_missing', { member: bridge.member })); } const request = context.request as Request; @@ -236,6 +228,32 @@ export async function handleOwnDoorBridgeRequest( } } +/** + * [#37737] The answer for a `501` whose sentence is in the request's language + * (read by {@link requestLocaleOf}), with the `Vary: Accept-Language` such a + * body owes. A `501` is cacheable by default (RFC 9111 §4.2.2: a shared cache + * may store it with no explicit freshness), so without the header a cache in + * front of the API could hand one reader's language to the next. Every door + * that answers a localized `501` answers through this. + */ +export function localizedNotImplemented(deps: DomainHandlerDeps, message: string): HttpDispatcherResult { + const response = deps.error(message, 501) as NonNullable; + return { handled: true, response: { ...response, headers: { ...(response.headers ?? {}), Vary: 'Accept-Language' } } }; +} + +/** + * [#37737] {@link localizedNotImplemented} for one sentence of the operation + * message catalog, in the request's top `Accept-Language` tag. + */ +export function catalogNotImplemented( + deps: DomainHandlerDeps, + context: HttpProtocolContext, + key: string, + params?: Record, +): HttpDispatcherResult { + return localizedNotImplemented(deps, operationUserMessage(key, { locale: requestLocaleOf(context) }, params)); +} + /** A `501` sentence of the catalog, in the request's top `Accept-Language` tag. */ function notImplementedSentence( bridge: OwnDoorBridge, @@ -251,8 +269,11 @@ function notImplementedSentence( /** * 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). + * header record: the language of an own door's `501`. The doors that are not + * bridges read it for their own `501`s too: the comment doors (`comments.ts`) + * and the webhook redelivery door (`webhooks.ts`, both #37610), the approval + * action-page door (`approvals.ts`) and the inbound automation hooks + * (`automation-hooks.ts`, both #37662). */ export function requestLocaleOf(context: HttpProtocolContext): string | undefined { const headers = (context.request as { headers?: unknown } | undefined)?.headers as diff --git a/packages/runtime/src/domains/webhooks-redeliver.test.ts b/packages/runtime/src/domains/webhooks-redeliver.test.ts index 7051d38b75f..1b7973a898c 100644 --- a/packages/runtime/src/domains/webhooks-redeliver.test.ts +++ b/packages/runtime/src/domains/webhooks-redeliver.test.ts @@ -368,6 +368,8 @@ describe('[#37610] the redelivery door\'s 501 follows the request\'s language', const label = JSON.stringify(headers); const result = await dispatcher.dispatch('POST', REDELIVER, {}, {}, ctx(request)); expect(envelope(result), label).toEqual({ status: 501, code: 'NOT_IMPLEMENTED' }); + // [#37737] The body is in the request's language, so the answer says it varies by it. + expect(result.response?.headers?.Vary, label).toBe('Accept-Language'); 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 a33c00fb3e2..caf78113535 100644 --- a/packages/runtime/src/domains/webhooks.ts +++ b/packages/runtime/src/domains/webhooks.ts @@ -78,11 +78,10 @@ */ 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'; +import { catalogNotImplemented } from './own-door-bridge.js'; /** * The one path this domain claims — exactly, with no sub-paths: the redeliver @@ -118,22 +117,10 @@ export async function handleWebhooksRedeliverRequest( // [#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( - operationUserMessage('webhook_redeliver_service_unregistered', { locale: requestLocaleOf(context) }), - 501, - ), - }; + return catalogNotImplemented(deps, context, 'webhook_redeliver_service_unregistered'); } if (typeof service.handleRedeliver !== 'function') { - return { - handled: true, - response: deps.error( - operationUserMessage('webhook_redeliver_member_missing', { locale: requestLocaleOf(context) }), - 501, - ), - }; + return catalogNotImplemented(deps, context, 'webhook_redeliver_member_missing'); } const request = context.request as Request; diff --git a/packages/spec/src/system/operation-message.ts b/packages/spec/src/system/operation-message.ts index a5f0376bb9f..cafa9f899d2 100644 --- a/packages/spec/src/system/operation-message.ts +++ b/packages/spec/src/system/operation-message.ts @@ -332,7 +332,10 @@ export function operationMessageTranslationKey(messageKey: string): string { * catalog is the only source of their text. * - `Accept-Language` is read by its top tag only * (`preferredLocaleFromHeader`, no q-value negotiation), the platform's - * existing reading; a top tag the catalog lacks answers English. + * existing reading. The tag is matched to a catalog locale by language + * (`resolveBundleLocale`): `es-MX` reads `es-ES`, `zh` and `zh-TW` read + * `zh-CN`, `ja` reads `ja-JP`. Only a language the catalog holds no + * locale of (`fr`, `de`, …) answers English. * - The server fault log records the thrown error's own message. Only a * throw with an EMPTY message puts the localized sentence into the log line * in its place (`serverFaultLogMessage`'s fallback); every other throw logs @@ -377,8 +380,9 @@ export function operationMessageTranslationKey(messageKey: string): string { * (`automation-hooks.ts`), which are not own-door bridges: each sentence is * whole, with its slot, member and package names written in, never * translated. Each door reads them as the bridge does: by the request's top - * `Accept-Language` tag (`requestLocaleOf`, `own-door-bridge.ts`), a top tag - * the catalog lacks answering English, and with no `i18n` service, so no + * `Accept-Language` tag (`requestLocaleOf`, `own-door-bridge.ts`), matched to + * a catalog locale by language as the print door's is (a language the catalog + * holds no locale of answering English), and with no `i18n` service, so no * `errors.comment_doors_*`, `errors.webhook_redeliver_*`, * `errors.approvals_act_*` or `errors.automation_hooks_*` override is * consulted. Their English is byte-identical to the fixed sentences the doors @@ -632,9 +636,9 @@ export const BUILTIN_OPERATION_MESSAGES: Record> approvals_act_member_missing: '承認アクションページは利用できません。登録されている approvals サービスは handleActionPage を実装していません。', automation_hooks_service_unregistered: - '受信オートメーションフックは利用できません。trigger-api サービスが登録されていません。受信フックトリガー(@objectstack/trigger-api)がこのサービスを通じてこのルートを提供します。フローを所有する環境に組み込んでください。', + '受信自動化フックは利用できません。trigger-api サービスが登録されていません。受信フックトリガー(@objectstack/trigger-api)がこのサービスを通じてこのルートを提供します。フローを所有する環境に組み込んでください。', automation_hooks_member_missing: - '受信オートメーションフックは利用できません。登録されている trigger-api サービスは handleInboundHook を実装していません。', + '受信自動化フックは利用できません。登録されている trigger-api サービスは handleInboundHook を実装していません。', }, 'es-ES': { permission_denied: From 620499a87efcac52eb3f6c413a7c30a2c3268041 Mon Sep 17 00:00:00 2001 From: Claude Date: Fri, 27 Nov 2026 04:38:13 +0000 Subject: [PATCH 2/2] chore(scripts): declare the localized 501's Vary header as own-door-bridge.ts's one hand-built answer check-route-envelope counts response object literals per domain module; localizedNotImplemented spreads deps.error's envelope and adds Vary: Accept-Language, which deps.error cannot express. Co-Authored-By: Claude Claude-Session: https://claude.ai/code/session_01L6bhgUpnvPnJ1hR74pUrVj --- scripts/check-route-envelope.mjs | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/scripts/check-route-envelope.mjs b/scripts/check-route-envelope.mjs index 2a29dcf3edb..b8ce285426c 100644 --- a/scripts/check-route-envelope.mjs +++ b/scripts/check-route-envelope.mjs @@ -1149,8 +1149,12 @@ const DISPATCHER_DOMAINS = { // `/attachments` and `/print` call. The member's own JSON `Response` is handed back as // `result`, and every answer the bridge makes itself — the ordinary miss, // the two 501s, the sanitised 500s — goes through `deps.routeNotFound` / - // `deps.error`. - 'own-door-bridge.ts': { handBuilt: 0 }, + // `deps.error`. [#37737] The 501s, and the other doors' localized 501s, + // gain one header on top of `deps.error`'s envelope, the one hand-built site. + 'own-door-bridge.ts': { + handBuilt: 1, + note: 'the localized 501 (`localizedNotImplemented`, #37737), which must carry `Vary: Accept-Language` (`deps.error` takes no headers); the body is `deps.error`\'s declared envelope spread, and every door that answers a 501 in the request\'s language answers through it', + }, 'packages.ts': { handBuilt: 0 }, // The `/security` domain's permission-set clone door (ADR-0126 §7.1), beside // the activation door. Every answer goes through `deps.success` /