Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions .changeset/37811-domain-501-languages.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
---
'@objectstack/runtime': patch
'@objectstack/spec': patch
---

fix(runtime): the dispatcher's remaining 501 answers follow the request's language

Clause-②: yes (widening)
Metadata-protocol: none
Skills-docs: none (no page under `skills/**` quotes these 501 sentences or their headers)

The `501 NOT_IMPLEMENTED` answers of `/auth`, `/i18n`, `/mcp`, `/meta`, `/packages`, `/automation` (the connector credential and connection doors, the run list, cancel, restore, resume, screen lookup and flow clone), the action and catalog activation doors, the permission-set clone door, the `/security` suggested-binding reopen and `/share-links` now answer in the request's top `Accept-Language` tag, as the own doors' `501`s do since #37721, and carry `Vary: Accept-Language`. Each sentence is a new key of the operation-message catalog in `en`, `zh-CN`, `ja-JP` and `es-ES`; the English is byte for byte the sentence the door answered before, and status and code are unchanged.

Three `501`s stay English: the shared `capabilityUnavailable` answer, whose sentence is the discovery remedy (`services.<slot>.message`) by contract; the MCP resume door's, which the calling agent reads beside the door's other English refusals; and the `/meta` save fallback that forwards the metadata service's own thrown message.
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
// was written would still be the leak commit 02b41232d measured, with persistence.

import { describe, it, expect, vi } from 'vitest';
import { BUILTIN_OPERATION_MESSAGES } from '@objectstack/spec/system';

import { HttpDispatcher } from '../http-dispatcher.js';
import type { HttpProtocolContext } from '../http-dispatcher.js';
Expand Down Expand Up @@ -463,3 +464,24 @@ describe('the activation write names the caller who asked for it', () => {
expect(options?.context?.userId).toBe((ctx.executionContext as { userId: string }).userId);
});
});

// [#37811] This door's 501 sentence is the operation-message catalog's, in the
// request's top `Accept-Language` tag: byte-identical English with no header,
// the catalog's Japanese under `ja-JP`, and `Vary: Accept-Language` either way.
const JA_37811 = { request: { headers: { 'accept-language': 'ja-JP,ja;q=0.9' } } };
const LANGS_37811 = [['en', {}], ['ja-JP', JA_37811]] as const;
const sentence37811 = (locale: 'en' | 'ja-JP', key: string, params: Record<string, string> = {}): string =>
BUILTIN_OPERATION_MESSAGES[locale][key].replace(/\{\{(\w+)\}\}/g, (_m, name: string) => params[name] ?? '');
const vary37811 = (response: unknown): unknown => (response as any)?.headers?.Vary;

describe('[#37811] the no-ledger 501 follows the request\'s language', () => {
it('action_activation_ledger_unsupported', async () => {
for (const [locale, extra] of LANGS_37811) {
const h = boot('single', { omitLedger: true });
const res = await flip(h, { ...TENANT_ADMIN(), ...extra } as HttpProtocolContext);
expect(statusOf(res)).toBe(501);
expect(messageOf(res)).toBe(sentence37811(locale, 'action_activation_ledger_unsupported'));
expect(vary37811(res.response)).toBe('Accept-Language');
}
});
});
10 changes: 2 additions & 8 deletions packages/runtime/src/domains/actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ import { refusedNameAnswer } from './catalog-activation.js';
import type { HttpProtocolContext, HttpDispatcherResult } from '../http-dispatcher.js';
import type { DomainHandlerDeps, DomainRoute } from '../domain-handler-registry.js';
import { readDispatchedBody } from '../deferred-request-body.js';
import { catalogNotImplemented } from './own-door-bridge.js';

/**
* [ADR-0126 §8 item 2] The reserved first segment of the activation door,
Expand Down Expand Up @@ -273,14 +274,7 @@ async function handleActionActivationWrite(
if (typeof ql.setActionActive !== 'function') {
// An engine too old to carry the projection cannot make this durable,
// and a 200 here would report a switch that never existed.
return {
handled: true,
response: deps.error(
`This deployment's data engine does not implement the packaged-metadata activation ledger ` +
`(ADR-0126 §8), so a packaged action cannot be switched off here.`,
501,
),
};
return catalogNotImplemented(deps, context, 'action_activation_ledger_unsupported');
}
try {
// An action no package ships carries NO package key: absent is the
Expand Down
3 changes: 2 additions & 1 deletion packages/runtime/src/domains/auth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import { INTERNAL_ERROR_MESSAGE } from '@objectstack/types';
import { CoreServiceName } from '@objectstack/spec/system';
import type { HttpProtocolContext, HttpDispatcherResult } from '../http-dispatcher.js';
import type { DomainHandlerDeps, DomainRoute } from '../domain-handler-registry.js';
import { catalogNotImplemented } from './own-door-bridge.js';

/**
* The route this domain claims — `/auth` and its slash-separated sub-paths,
Expand Down Expand Up @@ -188,7 +189,7 @@ export async function handleAuthRequest(deps: DomainHandlerDeps, _path: string,
// faith with the one true observation the mock was built on — that a bare
// 404 on sign-in sends the operator hunting for a routing bug — without
// the lie it used to answer that concern.
return { handled: true, response: deps.error('Auth service not available — register @objectstack/plugin-auth to enable authentication', 501) };
return catalogNotImplemented(deps, context, 'auth_service_unavailable');
}

/** The transport's peer address (`IHttpRequest.remoteAddress`), when the request carries one. */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
// (`connector-connection-door.test.ts`).

import { describe, it, expect, vi } from 'vitest';
import { BUILTIN_OPERATION_MESSAGES } from '@objectstack/spec/system';
// The stack loads the metadata service lazily; pay that load at collection, never in a clocked case.
import '@objectstack/metadata';

Expand Down Expand Up @@ -470,3 +471,32 @@ describe('ADR-0143 D2.1 — connector connection door: the begin leg takes the i
expect(h.revoke).toHaveBeenCalledWith({ connector: 'crm', context: expect.objectContaining({ tenantId: 'org_a' }) });
});
});

// [#37811] This door's 501 sentence is the operation-message catalog's, in the
// request's top `Accept-Language` tag: byte-identical English with no header,
// the catalog's Japanese under `ja-JP`, and `Vary: Accept-Language` either way.
const JA_37811 = { request: { headers: { 'accept-language': 'ja-JP,ja;q=0.9' } } };
const LANGS_37811 = [['en', {}], ['ja-JP', JA_37811]] as const;
const sentence37811 = (locale: 'en' | 'ja-JP', key: string, params: Record<string, string> = {}): string =>
BUILTIN_OPERATION_MESSAGES[locale][key].replace(/\{\{(\w+)\}\}/g, (_m, name: string) => params[name] ?? '');
const vary37811 = (response: unknown): unknown => (response as any)?.headers?.Vary;

describe('[#37811] the absent-member 501 follows the request\'s language and names the member', () => {
it('automation_connector_connections_unsupported, on the read, begin, revoke and callback legs', async () => {
const h = boot({ service: { handlerReady: true } });
for (const [locale, extra] of LANGS_37811) {
const ctx = { ...ADMIN(), ...extra } as HttpProtocolContext;
for (const [call, member] of [
[() => connection(h, 'GET', ctx), 'getConnectorConnection'],
[() => connection(h, 'POST', ctx), 'beginConnectorConnection'],
[() => connection(h, 'DELETE', ctx), 'revokeConnectorConnection'],
[() => callback(h, ctx, { code: AUTH_CODE, state: 's' }), 'completeConnectorConnection'],
] as const) {
const { response } = await call();
expect(statusOf(response)).toBe(501);
expect(messageOf(response)).toBe(sentence37811(locale, 'automation_connector_connections_unsupported', { member }));
expect(vary37811(response)).toBe('Accept-Language');
}
}
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@
// (`connector-credential-door.test.ts`).

import { describe, it, expect, vi } from 'vitest';
// [#37811] Paid at collection: the dispatcher's reach loads `@objectstack/metadata` (check:test-source-alias).
import '@objectstack/metadata';
import { BUILTIN_OPERATION_MESSAGES } from '@objectstack/spec/system';

import { HttpDispatcher } from '../http-dispatcher.js';
import type { HttpProtocolContext } from '../http-dispatcher.js';
Expand Down Expand Up @@ -236,3 +239,31 @@ describe('[#27237] connector credential door — what it accepts', () => {
}
});
});

// [#37811] This door's 501 sentence is the operation-message catalog's, in the
// request's top `Accept-Language` tag: byte-identical English with no header,
// the catalog's Japanese under `ja-JP`, and `Vary: Accept-Language` either way.
const JA_37811 = { request: { headers: { 'accept-language': 'ja-JP,ja;q=0.9' } } };
const LANGS_37811 = [['en', {}], ['ja-JP', JA_37811]] as const;
const sentence37811 = (locale: 'en' | 'ja-JP', key: string, params: Record<string, string> = {}): string =>
BUILTIN_OPERATION_MESSAGES[locale][key].replace(/\{\{(\w+)\}\}/g, (_m, name: string) => params[name] ?? '');
const vary37811 = (response: unknown): unknown => (response as any)?.headers?.Vary;

describe('[#37811] the absent-member 501 follows the request\'s language and names the member', () => {
it('automation_connector_credentials_unsupported, on the list, set and clear legs', async () => {
const h = boot({ service: { handlerReady: true } });
for (const [locale, extra] of LANGS_37811) {
const ctx = { ...ADMIN(), ...extra } as HttpProtocolContext;
for (const [call, member] of [
[() => get(h, ctx), 'listConnectorCredentialRefs'],
[() => put(h, ctx, { value: DUMMY_VALUE }), 'setConnectorCredential'],
[() => del(h, ctx), 'clearConnectorCredential'],
] as const) {
const { response } = await call();
expect(statusOf(response)).toBe(501);
expect(messageOf(response)).toBe(sentence37811(locale, 'automation_connector_credentials_unsupported', { member }));
expect(vary37811(response)).toBe('Accept-Language');
}
}
});
});
28 changes: 28 additions & 0 deletions packages/runtime/src/domains/automation-run-lifecycle-door.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
*/

import { describe, it, expect, vi } from 'vitest';
import { BUILTIN_OPERATION_MESSAGES } from '@objectstack/spec/system';
import '@objectstack/metadata';

import { HttpDispatcher } from '../http-dispatcher.js';
Expand Down Expand Up @@ -579,3 +580,30 @@ describe('#13953 — the run-lifecycle doors require the platform operator', ()
});
});
});

// [#37811] This door's 501 sentence is the operation-message catalog's, in the
// request's top `Accept-Language` tag: byte-identical English with no header,
// the catalog's Japanese under `ja-JP`, and `Vary: Accept-Language` either way.
const JA_37811 = { request: { headers: { 'accept-language': 'ja-JP,ja;q=0.9' } } };
const LANGS_37811 = [['en', {}], ['ja-JP', JA_37811]] as const;
const sentence37811 = (locale: 'en' | 'ja-JP', key: string, params: Record<string, string> = {}): string =>
BUILTIN_OPERATION_MESSAGES[locale][key].replace(/\{\{(\w+)\}\}/g, (_m, name: string) => params[name] ?? '');
const vary37811 = (response: unknown): unknown => (response as any)?.headers?.Vary;

describe('[#37811] the absent-member 501s follow the request\'s language', () => {
for (const [path, options, key] of [
[CANCEL_PATH, { cancel: 'absent' }, 'automation_run_cancel_unsupported'],
[RESTORE_PATH, { restore: 'absent' }, 'automation_run_restore_unsupported'],
] as const) {
it(key, async () => {
for (const [locale, extra] of LANGS_37811) {
const { response } = await makeDispatcher(options as HarnessOptions).dispatcher.handleAutomation(
path, 'POST', undefined, { ...OPERATOR_CTX(), ...extra } as HttpProtocolContext, undefined,
);
expect(statusOf(response)).toBe(501);
expect(messageOf(response)).toBe(sentence37811(locale, key));
expect(vary37811(response)).toBe('Accept-Language');
}
});
}
});
26 changes: 26 additions & 0 deletions packages/runtime/src/domains/automation-screen-read-gate.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,9 @@
*/

import { describe, it, expect, vi } from 'vitest';
// [#37811] Paid at collection: the dispatcher's reach loads `@objectstack/metadata` (check:test-source-alias).
import '@objectstack/metadata';
import { BUILTIN_OPERATION_MESSAGES } from '@objectstack/spec/system';

import { HttpDispatcher } from '../http-dispatcher.js';
import type { HttpProtocolContext } from '../http-dispatcher.js';
Expand Down Expand Up @@ -527,3 +530,26 @@ describe('#7968 — the paused-run screen is gated to its trigger identity, or t
});
});
});

// [#37811] This door's 501 sentence is the operation-message catalog's, in the
// request's top `Accept-Language` tag: byte-identical English with no header,
// the catalog's Japanese under `ja-JP`, and `Vary: Accept-Language` either way.
const JA_37811 = { request: { headers: { 'accept-language': 'ja-JP,ja;q=0.9' } } };
const LANGS_37811 = [['en', {}], ['ja-JP', JA_37811]] as const;
const sentence37811 = (locale: 'en' | 'ja-JP', key: string, params: Record<string, string> = {}): string =>
BUILTIN_OPERATION_MESSAGES[locale][key].replace(/\{\{(\w+)\}\}/g, (_m, name: string) => params[name] ?? '');
const vary37811 = (response: unknown): unknown => (response as any)?.headers?.Vary;

describe('[#37811] the screen-lookup 501 follows the request\'s language', () => {
it('automation_screen_lookup_unsupported', async () => {
for (const [locale, extra] of LANGS_37811) {
const h = makeDispatcher('refusing', { withoutScreenLookup: true });
const { response } = await h.dispatcher.handleAutomation(
SCREEN_PATH, 'GET', undefined, { ...STRANGER(), ...extra } as HttpProtocolContext, undefined,
);
expect((response as any).status).toBe(501);
expect((response as any).body?.error?.message).toBe(sentence37811(locale, 'automation_screen_lookup_unsupported'));
expect(vary37811(response)).toBe('Accept-Language');
}
});
});
Loading
Loading