Skip to content

Commit 0ad4f48

Browse files
test(mcp,runtime): pin the dataset tools' degraded read when the i18n service's reads throw (#35029)
<!-- claude-projects-attribution: {"github_login":"os-support-ai"} --> _Requested by **Yibo Wang** · [project thread](https://claude.ai/code/project/chan_01BVUyyPie8gHwoPM18iABwB?thread=cmsg_01BVUyyPie8gHwoPM18iABwBLW6dHPW6sSheA32XPKZzPV)_ repo:objectstack#3 · os-support-ai · session_01WGufzg2evNa1V3zxrQq3KX Closes #34876 Clause-②: no Metadata-protocol: none ## 维护者速读 - 改了什么:只加测试。在 stdio 与 HTTP 两个 MCP 入口各加一组用例,钉住"i18n 服务能解析到、但 getLocales / getTranslations 抛错"时数据集工具的现有回答。 - 为什么改:这个降级路径此前没有任何测试,后续改动可能把它悄悄变成别的回答。席位裁决 A:现有回答(目录清空并标 partial、查询 503)就是要钉住的回答。 - 风险与回滚:零运行时风险,不改任何源码,发布产物不含测试文件。回滚即还原这两个测试文件。 - 先看:packages/runtime/src/mcp-dataset-tools-bridge.test.ts 末尾新增的 describe;packages/mcp/src/stdio-data-bridge.dataset-locale.test.ts 末尾新增的 describe。 - 两分钟验证:pnpm --filter @objectstack/mcp exec vitest run src/stdio-data-bridge.dataset-locale.test.ts,预期 9 个用例全绿(其中 5 个为本 PR 新增)。 - 需要你做的:无,席位落地。 ## Premise correction The card said a resolved i18n service whose `getLocales` / `getTranslations` throws makes the dataset catalogue fall back to untranslated text. Measured, it does not (premise report on the card, comment 6962311179; claim amendment 6962350323). `translationBundleOf` calls both reads with no guard, so `translateMetaList` rejects with the i18n error. `loadDatasets` does not catch that on either transport, and the dataset executor answers the throw as a degraded read: `list_datasets` returns `datasets: []`, `partial: true` and the warning "The dataset catalogue could not be read: MSG"; `query_dataset` refuses 503 `SERVICE_UNAVAILABLE`. Seat ruling A: pin that answer. A follow-up (B: serve the untranslated text on a translation fault, inside the shared translator) would flip these pins on purpose. Re-measured on `origin/main` 4443014, the base of this branch: the answer has not changed since db1a05c, and none of the source files involved changed between the two commits. ## What changes Tests only. No source file is edited. - `packages/mcp/src/stdio-data-bridge.dataset-locale.test.ts` (the shared harness for this seam): a new top-level `describe` that drives `createStdioDataBridge` over the REAL executor. That executor is the analytics service `AnalyticsServicePlugin` registers, with admission wired, over an open security double and an engine double that declares the dataset's object. - `packages/runtime/src/mcp-dataset-tools-bridge.test.ts` (the harness of the real HTTP door, `packages/runtime/src/domains/mcp.ts`): the same `describe` through `buildMcpBridge`, with the i18n service resolved through the request's `resolveService`, over the same real executor. Each `describe` has: - a control case: when the i18n reads answer, the same harness lists the dataset in its bundle label. This shows that an empty catalogue in the throwing cases comes from the failed read, not from the harness; - for `getLocales` throwing and for `getTranslations` throwing: `list_datasets` equals `{ datasets: [], partial: true, warning }`, where the warning starts "The dataset catalogue could not be read: " and names the i18n error; - for the same two throws: `query_dataset` refuses with `code: 'SERVICE_UNAVAILABLE'`, `status: 503`, and a message that names the failed read and the i18n error ("the dataset read failed (MSG)"). That message tells it apart from the executor's other 503, "not available on this deployment". The comment on each `describe` says the answer is pinned on purpose under seat ruling A, and that follow-up B would flip it deliberately. ## Tests All at head 0cdcef6. - `pnpm --filter @objectstack/mcp test`: Test Files 71 passed (71), Tests 1257 passed (1257), exit 0. - `pnpm --filter @objectstack/runtime test`: Test Files 618 passed (618), Tests 11459 passed, 23 skipped (11482), exit 0. - `pnpm --filter @objectstack/mcp typecheck` and `pnpm --filter @objectstack/runtime typecheck`: lock VERDICT command-exit 0. Both packages' `check:test-typecheck` compile the two edited test files, and the debt ledgers are unchanged. ### Ablation (one per pin, then restored) The ablation is the one the claim named: catch `translateMetaList` in `loadDatasets` and fall back to the untranslated items. It was applied through `node scripts/ablation-replace.mjs` (wrap mode: the anchor must hit exactly once, the mutation is proven on disk, and the restore is proven by `blob == HEAD` and an empty `git diff HEAD`). Both test files import the door under test by relative path (`./stdio-data-bridge.js`, `./domains/mcp.js`), so the tests read `src/` and no `dist/` rebuild sits between mutation and run. <details><summary>stdio: packages/mcp/src/stdio-data-bridge.ts, 4 failed / 5 passed (9), then restored</summary> ```text ablation-replace: ok mutation landed: anchor 1 -> 0, blob f4f5d63 -> e3a455986ba4 ❯ src/stdio-data-bridge.dataset-locale.test.ts (9 tests | 4 failed) × 'getLocales' throwing: list_datasets lists nothing, says partial and names the i18n error × 'getTranslations' throwing: list_datasets lists nothing, says partial and names the i18n error × 'getLocales' throwing: query_dataset refuses 503 SERVICE_UNAVAILABLE, naming the failed read × 'getTranslations' throwing: query_dataset refuses 503 SERVICE_UNAVAILABLE, naming the failed read AssertionError: expected { datasets: [ { …(6) } ] } to deeply equal { datasets: [], partial: true, …(1) } - "datasets": [], - "partial": true, - "warning": StringContaining "locales exploded", + "datasets": [ { "name": "opp_metrics", "label": "Opportunity Metrics", ... } ], AssertionError: expected undefined to match object { code: 'SERVICE_UNAVAILABLE', …(1) } os-verify-lock: VERDICT command-exit 1 ablation-replace: ok restored: blob == HEAD (f4f5d63) and `git diff HEAD` is empty ``` </details> <details><summary>HTTP door: packages/runtime/src/domains/mcp.ts, 4 failed / 7 passed (11), then restored</summary> ```text ablation-replace: ok mutation landed: anchor 1 -> 0, blob b4a8eb6 -> dd2d96eb1cb2 ❯ |local| src/mcp-dataset-tools-bridge.test.ts (11 tests | 4 failed) × 'getLocales' throwing: list_datasets lists nothing, says partial and names the i18n error × 'getTranslations' throwing: list_datasets lists nothing, says partial and names the i18n error × 'getLocales' throwing: query_dataset refuses 503 SERVICE_UNAVAILABLE, naming the failed read × 'getTranslations' throwing: query_dataset refuses 503 SERVICE_UNAVAILABLE, naming the failed read AssertionError: expected { datasets: [ { …(5) } ] } to deeply equal { datasets: [], partial: true, …(1) } - "datasets": [], - "partial": true, - "warning": StringContaining "locales exploded", + "datasets": [ { "name": "sales_analysis", "label": "Sales analysis", ... } ], AssertionError: expected undefined to match object { code: 'SERVICE_UNAVAILABLE', …(1) } os-verify-lock: VERDICT command-exit 1 ablation-replace: ok restored: blob == HEAD (b4a8eb6) and `git diff HEAD` is empty ``` </details> Under the ablation, the catalogue lists the dataset untranslated and `query_dataset` resolves with no refusal: that is answer B, so every throwing case goes red. After the restore, `git status --porcelain` is empty. ## Acceptance notes - An earlier draft of the stdio pins ran over the executor with no security or engine double. Under the ablation it still answered `datasets: []` (permissions could not be resolved), so only the warning told the two apart. The final harness admits the dataset (see the control case), so under the ablation `datasets` really does carry the untranslated entry. - Changeset: none. The diff edits two `*.test.ts` files; both packages publish `files: ["dist", "README.md", "CHANGELOG.md"]`. After building both packages, a search of `dist/` for a test-only symbol (`i18nWhoseReadThrows` / `locales exploded`) found 0 files in each, and the positive control (`translateMetaList`) found 2 files in mcp and 3 in runtime. Declared `skip-changeset`. - The object tools (`list_objects` / `describe`) call the same unguarded translator on both transports. That is read from the code, not driven, and stays outside this card; follow-up B covers it. ## Verification <details><summary>Derived gate families (dispatch-gates --commands at 0cdcef6): 50 derived, 49 run green, 1 NOT MEASURED</summary> - `node scripts/pm/dispatch-gates.mjs --ran` (with per-command exit codes): "50 derived famil(ies) accounted for — 49 run, 1 NOT-MEASURED". - 49 commands exited 0. They include `check:cross-package-test-inputs`, `check:test-source-alias`, `check:engine-double-contract`, `check:nul-bytes`, `check:issue-citations`, `check:doc-authoring`, `check:type-check-coverage`, `check:type-check-debt`, `check:undeclared-dep-imports` and `check:published-files`. - NOT MEASURED: `pnpm check:dual-build-cjs-loads` exited 3, PREREQUISITE NOT MET (it reads every package's built `dist/`, and this worktree built only the mcp/runtime closure). CI runs it. - `node scripts/pm/overlap-check.mjs`: "VERDICT clean exit 0" (origin/main merges cleanly, 0 open PRs share a file). - The full CI farm (Lint and Repo Gates, Test Core, Build Core and the rest) is CI's to run. This report cites no CI verdict because CI had not finished when it was written. </details> --- _Generated by [Claude Code](https://claude.ai/code/session_01WGufzg2evNa1V3zxrQq3KX)_ <!-- signed: repo:objectstack#3 · os-support-ai · session_01WGufzg2evNa1V3zxrQq3KX --> --------- Co-authored-by: Claude <noreply@anthropic.com>
1 parent 4df62e6 commit 0ad4f48

2 files changed

Lines changed: 248 additions & 2 deletions

File tree

‎packages/mcp/src/stdio-data-bridge.dataset-locale.test.ts‎

Lines changed: 121 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,20 @@
2121
* - an `en` default: today's answer — the authored labels, and no hit for the
2222
* zh-CN bundle term;
2323
* - an i18n service the host cannot resolve (its resolver throws), or none:
24-
* the untranslated list, never an error.
24+
* the untranslated list, never an error;
25+
* - an i18n service that resolves but whose `getLocales` / `getTranslations`
26+
* throws, over the REAL executor: a degraded read on both dataset tools
27+
* (seat ruling A, its own describe below).
2528
*/
2629

2730
import { describe, it, expect } from 'vitest';
2831
import type { ListDatasetsOutput } from '@objectstack/spec/ai';
29-
import { matchDatasetTerms, type MatchableMember } from '@objectstack/service-analytics';
32+
import {
33+
AnalyticsServicePlugin,
34+
matchDatasetTerms,
35+
type AnalyticsService,
36+
type MatchableMember,
37+
} from '@objectstack/service-analytics';
3038
import { createStdioDataBridge, type StdioDataBridgeDeps, type StdioDatasetToolsService } from './stdio-data-bridge.js';
3139

3240
const PRINCIPAL = { userId: 'u_key', tenantId: 'org_1' };
@@ -141,3 +149,114 @@ describe('[ADR-0149 D2] stdio list_datasets is localized for the workspace defau
141149
expect(answer.datasets[0].measures.map((m) => m.label)).toEqual(['Total Amount']);
142150
});
143151
});
152+
153+
/**
154+
* [ADR-0149 D2] An i18n service that RESOLVES but whose reads throw is not the
155+
* unresolvable service above. `translationBundleOf` calls `getLocales` and
156+
* `getTranslations` unguarded, so `translateMetaList` rejects with the i18n
157+
* error, and `loadDatasets` leaves that rejection to throw. The executor here
158+
* is the REAL one (the analytics service `AnalyticsServicePlugin` registers,
159+
* admission wired), so the answer is the executor's own degraded-read
160+
* contract: `list_datasets` lists nothing, says `partial` and names the error;
161+
* `query_dataset` refuses 503 `SERVICE_UNAVAILABLE` for a server-side fault.
162+
* The control case lists the dataset over the same harness, so the empty
163+
* catalogue is the failed read's doing, not the harness's.
164+
*
165+
* Pinned on purpose under seat ruling A: the catalogue degrades and says so.
166+
* A follow-up (B: serve the untranslated text on a translation fault, inside
167+
* the shared translator) would flip these expectations deliberately, on both
168+
* transports at once.
169+
*/
170+
describe('[ADR-0149 D2] stdio dataset tools when the i18n service resolves but its reads throw', () => {
171+
/**
172+
* The analytics service AnalyticsServicePlugin registers, so the executor is
173+
* the platform's own; over an open security double and an engine double
174+
* that declares `crm_opportunity`, so a dataset the load hands over IS
175+
* listed (the control case below), and an empty catalogue is the load's doing.
176+
*/
177+
async function wiredAnalytics(): Promise<AnalyticsService> {
178+
const fields = { id: { type: 'text' }, stage: { type: 'text' }, amount: { type: 'number' } };
179+
const engine = {
180+
execute: async () => ({ rows: [{ stage: 'won', total_amount: 100 }] }),
181+
hasObjectMiddleware: () => false,
182+
getObject: (name: string) => (name === 'crm_opportunity' ? { fields } : undefined),
183+
resolveEffectiveDatasource: () => undefined,
184+
};
185+
const security = {
186+
getReadFilter: async () => undefined,
187+
canReadObject: () => true,
188+
getReadableFields: async () => Object.keys(fields),
189+
getQueryableFields: async () => Object.keys(fields),
190+
};
191+
const registered: Record<string, unknown> = { data: engine, security };
192+
const ctx = {
193+
getService: (name: string) => registered[name],
194+
registerService: (name: string, svc: unknown) => { registered[name] = svc; },
195+
replaceService: (name: string, svc: unknown) => { registered[name] = svc; },
196+
logger: { info() {}, warn() {}, error() {}, debug() {} },
197+
};
198+
await new AnalyticsServicePlugin({ queryCapabilities: () => ({ nativeSql: true, objectqlAggregate: false, inMemory: false }) }).init(ctx as never);
199+
const analytics = registered.analytics as AnalyticsService;
200+
expect(analytics.hasPluginWiredAdmission()).toBe(true);
201+
return analytics;
202+
}
203+
204+
/** A resolved i18n service whose `read` throws `message`; the other read answers the zh-CN bundle. */
205+
function i18nWhoseReadThrows(read: 'getLocales' | 'getTranslations', message: string) {
206+
return {
207+
getLocales: () => {
208+
if (read === 'getLocales') throw new Error(message);
209+
return ['zh-CN', 'en'];
210+
},
211+
getTranslations: (locale: string) => {
212+
if (read === 'getTranslations') throw new Error(message);
213+
return locale === 'zh-CN' ? ZH_CN : {};
214+
},
215+
getDefaultLocale: () => 'zh-CN',
216+
};
217+
}
218+
219+
async function bridgeOverRealExecutor(i18n: () => unknown) {
220+
return createStdioDataBridge({
221+
engine: {} as any,
222+
metadataService: { list: async () => [] } as any,
223+
protocol: () => ({ getMetaItems: async () => ({ items: [METRICS] }) }) as any,
224+
resolvePrincipal: async () => PRINCIPAL as any,
225+
datasetTools: await wiredAnalytics(),
226+
i18n,
227+
});
228+
}
229+
230+
const CASES = [
231+
{ read: 'getLocales' as const, message: 'locales exploded' },
232+
{ read: 'getTranslations' as const, message: 'bundle offline' },
233+
];
234+
235+
it('control: the same harness lists the dataset, in the bundle labels, when the reads answer', async () => {
236+
const bridge = await bridgeOverRealExecutor(() => i18nService('zh-CN'));
237+
const answer = await bridge.listDatasets!({});
238+
expect(answer.partial).toBeUndefined();
239+
expect(answer.datasets.map((d) => [d.name, d.label])).toEqual([['opp_metrics', '商机指标']]);
240+
});
241+
242+
it.each(CASES)('$read throwing: list_datasets lists nothing, says partial and names the i18n error', async ({ read, message }) => {
243+
const bridge = await bridgeOverRealExecutor(() => i18nWhoseReadThrows(read, message));
244+
const answer = await bridge.listDatasets!({ terms: TERMS });
245+
expect(answer).toEqual({ datasets: [], partial: true, warning: expect.stringContaining(message) });
246+
expect(answer.warning).toMatch(/^The dataset catalogue could not be read: /);
247+
});
248+
249+
it.each(CASES)('$read throwing: query_dataset refuses 503 SERVICE_UNAVAILABLE, naming the failed read', async ({ read, message }) => {
250+
const bridge = await bridgeOverRealExecutor(() => i18nWhoseReadThrows(read, message));
251+
const refused = await bridge
252+
.queryDataset!({ datasetName: 'opp_metrics', selection: { measures: ['total_amount'] } }, { maxRows: 10 })
253+
.then(
254+
() => undefined,
255+
(e: unknown) => e as { code?: unknown; status?: unknown; message?: unknown },
256+
);
257+
expect(refused).toMatchObject({ code: 'SERVICE_UNAVAILABLE', status: 503 });
258+
// The failed read's own 503 (naming the i18n error), not the executor's
259+
// "not available on this deployment" one.
260+
expect(refused?.message).toContain(`the dataset read failed (${message})`);
261+
});
262+
});

‎packages/runtime/src/mcp-dataset-tools-bridge.test.ts‎

Lines changed: 127 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,9 @@
1010
* carries no dataset member); the executor is bound to the saved datasets of
1111
* the protocol's merged read, to the request's security probe and to the tool
1212
* layer's page cap; and every call runs as the request's own principal.
13+
* Also pinned (its own describe below): an i18n service that resolves but
14+
* whose `getLocales` / `getTranslations` throws, over the REAL executor, is a
15+
* degraded read on both dataset tools (seat ruling A).
1316
*/
1417

1518
import { describe, it, expect, vi } from 'vitest';
@@ -18,6 +21,7 @@ import { describe, it, expect, vi } from 'vitest';
1821
import '@objectstack/metadata';
1922
import { HttpDispatcher } from './http-dispatcher.js';
2023
import { buildMcpBridge, resolveMcpDatasetToolsService, type McpDatasetToolsService } from './domains/mcp.js';
24+
import { AnalyticsServicePlugin, type AnalyticsService } from '@objectstack/service-analytics';
2125

2226
const EC = { userId: 'u1', tenantId: 'org_1', systemPermissions: [] };
2327
const SAVED = [{ name: 'sales_analysis', label: 'Sales analysis', object: 'crm_opportunity' }];
@@ -108,3 +112,126 @@ describe('[ADR-0149 D2] the MCP bridge\'s dataset members', () => {
108112
await expect(bound[0].loadDatasets(EC)).rejects.toThrow('metadata store down');
109113
});
110114
});
115+
116+
/**
117+
* [ADR-0149 D2] The HTTP door's dataset members when the request's i18n
118+
* service RESOLVES but its reads throw — not the lookup that throws, which
119+
* `metaTranslationSources` reads as none (text served untranslated).
120+
* `translationBundleOf` calls `getLocales` and `getTranslations` unguarded, so
121+
* the `/meta` list translation rejects with the i18n error, and `loadDatasets`
122+
* leaves that rejection to throw. The executor is the REAL one (the analytics
123+
* service `AnalyticsServicePlugin` registers, admission wired), so the answer
124+
* is its degraded-read contract: `list_datasets` lists nothing, says `partial`
125+
* and names the error; `query_dataset` refuses 503 `SERVICE_UNAVAILABLE`.
126+
* The control case lists the dataset over the same harness, so the empty
127+
* catalogue is the failed read's doing, not the harness's.
128+
*
129+
* Pinned on purpose under seat ruling A: the catalogue degrades and says so.
130+
* A follow-up (B: serve the untranslated text on a translation fault, inside
131+
* the shared translator) would flip these expectations deliberately, on both
132+
* transports at once.
133+
*/
134+
describe('[ADR-0149 D2] the HTTP dataset tools when the i18n service resolves but its reads throw', () => {
135+
const METRICS = {
136+
name: 'sales_analysis',
137+
label: 'Sales analysis',
138+
object: 'crm_opportunity',
139+
dimensions: [{ name: 'stage', label: 'Stage', field: 'stage', type: 'string' }],
140+
measures: [{ name: 'revenue', label: 'Revenue', aggregate: 'sum', field: 'amount' }],
141+
};
142+
const ZH_CN = { datasets: { sales_analysis: { label: '销售分析' } } };
143+
144+
/**
145+
* The analytics service AnalyticsServicePlugin registers, so the executor is
146+
* the platform's own; over an open security double and an engine double
147+
* that declares `crm_opportunity`, so a dataset the load hands over IS
148+
* listed (the control case below), and an empty catalogue is the load's doing.
149+
*/
150+
async function wiredAnalytics(): Promise<AnalyticsService> {
151+
const fields = { id: { type: 'text' }, stage: { type: 'text' }, amount: { type: 'number' } };
152+
const engine = {
153+
execute: async () => ({ rows: [{ stage: 'won', total_amount: 100 }] }),
154+
hasObjectMiddleware: () => false,
155+
getObject: (name: string) => (name === 'crm_opportunity' ? { fields } : undefined),
156+
resolveEffectiveDatasource: () => undefined,
157+
};
158+
const security = {
159+
getReadFilter: async () => undefined,
160+
canReadObject: () => true,
161+
getReadableFields: async () => Object.keys(fields),
162+
getQueryableFields: async () => Object.keys(fields),
163+
};
164+
const registered: Record<string, unknown> = { data: engine, security };
165+
const pluginCtx = {
166+
getService: (name: string) => registered[name],
167+
registerService: (name: string, svc: unknown) => { registered[name] = svc; },
168+
replaceService: (name: string, svc: unknown) => { registered[name] = svc; },
169+
logger: { info() {}, warn() {}, error() {}, debug() {} },
170+
};
171+
await new AnalyticsServicePlugin({ queryCapabilities: () => ({ nativeSql: true, objectqlAggregate: false, inMemory: false }) }).init(pluginCtx as never);
172+
const analytics = registered.analytics as AnalyticsService;
173+
expect(analytics.hasPluginWiredAdmission()).toBe(true);
174+
return analytics;
175+
}
176+
177+
/** A resolved i18n service whose `read` throws `message`; the other read answers a bundle. */
178+
function i18nWhoseReadThrows(read: 'getLocales' | 'getTranslations', message: string) {
179+
return {
180+
getLocales: () => {
181+
if (read === 'getLocales') throw new Error(message);
182+
return ['zh-CN', 'en'];
183+
},
184+
getTranslations: (locale: string) => {
185+
if (read === 'getTranslations') throw new Error(message);
186+
return locale === 'zh-CN' ? ZH_CN : {};
187+
},
188+
getDefaultLocale: () => 'zh-CN',
189+
};
190+
}
191+
192+
async function bridgeOverRealExecutor(i18n: unknown) {
193+
const analytics = await wiredAnalytics();
194+
const protocol = { getMetaItems: async ({ type }: { type: string }) => ({ type, items: type === 'dataset' ? [METRICS] : [] }) };
195+
const { ctx, deps } = harness({ analytics, i18n, protocol });
196+
expect(await resolveMcpDatasetToolsService(deps, ctx)).toBe(analytics);
197+
return buildMcpBridge(deps, ctx, { datasetTools: analytics });
198+
}
199+
200+
const CASES = [
201+
{ read: 'getLocales' as const, message: 'locales exploded' },
202+
{ read: 'getTranslations' as const, message: 'bundle offline' },
203+
];
204+
205+
it('control: the same harness lists the dataset, in the bundle label, when the reads answer', async () => {
206+
const answering = {
207+
getLocales: () => ['zh-CN', 'en'],
208+
getTranslations: (locale: string) => (locale === 'zh-CN' ? ZH_CN : {}),
209+
getDefaultLocale: () => 'zh-CN',
210+
};
211+
const bridge = await bridgeOverRealExecutor(answering);
212+
const answer = await bridge.listDatasets!({});
213+
expect(answer.partial).toBeUndefined();
214+
expect(answer.datasets.map((d: { name: string; label: string }) => [d.name, d.label])).toEqual([['sales_analysis', '销售分析']]);
215+
});
216+
217+
it.each(CASES)('$read throwing: list_datasets lists nothing, says partial and names the i18n error', async ({ read, message }) => {
218+
const bridge = await bridgeOverRealExecutor(i18nWhoseReadThrows(read, message));
219+
const answer = await bridge.listDatasets!({});
220+
expect(answer).toEqual({ datasets: [], partial: true, warning: expect.stringContaining(message) });
221+
expect(answer.warning).toMatch(/^The dataset catalogue could not be read: /);
222+
});
223+
224+
it.each(CASES)('$read throwing: query_dataset refuses 503 SERVICE_UNAVAILABLE, naming the failed read', async ({ read, message }) => {
225+
const bridge = await bridgeOverRealExecutor(i18nWhoseReadThrows(read, message));
226+
const refused = await bridge
227+
.queryDataset!({ datasetName: 'sales_analysis', selection: { measures: ['revenue'] } }, { maxRows: 10 })
228+
.then(
229+
() => undefined,
230+
(e: unknown) => e as { code?: unknown; status?: unknown; message?: unknown },
231+
);
232+
expect(refused).toMatchObject({ code: 'SERVICE_UNAVAILABLE', status: 503 });
233+
// The failed read's own 503 (naming the i18n error), not the executor's
234+
// "not available on this deployment" one.
235+
expect(refused?.message).toContain(`the dataset read failed (${message})`);
236+
});
237+
});

0 commit comments

Comments
 (0)