Skip to content

Commit a3fba9c

Browse files
committed
test(runtime): the new /mcp unit pins read the dispatcher result through a non-null assertion
`res.response` is optional on HttpDispatcherResult, so the nine new reads grew the file's test-typecheck debt (TS18048). The pre-existing reads in the file keep their ledgered spelling. Claude-Session: https://claude.ai/code/session_01SYEJqDL3NXxrJRBVqaMu9T Co-authored-by: Claude <noreply@anthropic.com>
1 parent b4159a3 commit a3fba9c

1 file changed

Lines changed: 9 additions & 9 deletions

File tree

‎packages/runtime/src/http-dispatcher.mcp.test.ts‎

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -206,43 +206,43 @@ describe('HttpDispatcher.handleMcp', () => {
206206
const { kernel } = makeKernel({ withMcp: true });
207207
const d = new HttpDispatcher(kernel, undefined, { enforceProjectMembership: false });
208208
const res = await d.handleMcp({}, makeContext({ executionContext: undefined }));
209-
expect(res.response.status).toBe(401);
210-
expect(res.response.body.error.code).toBe('UNAUTHENTICATED');
209+
expect(res.response!.status).toBe(401);
210+
expect(res.response!.body.error.code).toBe('UNAUTHENTICATED');
211211
});
212212

213213
it('anonymous → 401 UNAUTHENTICATED with no mcp service, not 501', async () => {
214214
process.env.OS_MCP_SERVER_ENABLED = 'true';
215215
const { kernel } = makeKernel({ withMcp: false });
216216
const d = new HttpDispatcher(kernel, undefined, { enforceProjectMembership: false });
217217
const res = await d.handleMcp({}, makeContext({ executionContext: undefined }));
218-
expect(res.response.status).toBe(401);
219-
expect(res.response.body.error.code).toBe('UNAUTHENTICATED');
218+
expect(res.response!.status).toBe(401);
219+
expect(res.response!.body.error.code).toBe('UNAUTHENTICATED');
220220
});
221221

222222
it('a system principal is still admitted: the switch-off 404 answers it', async () => {
223223
process.env.OS_MCP_SERVER_ENABLED = 'false';
224224
const { kernel } = makeKernel({ withMcp: true });
225225
const d = new HttpDispatcher(kernel, undefined, { enforceProjectMembership: false });
226226
const res = await d.handleMcp({}, makeContext({ executionContext: SYSTEM }));
227-
expect(res.response.status).toBe(404);
228-
expect(res.response.body.error.code).toBe('RESOURCE_NOT_FOUND');
227+
expect(res.response!.status).toBe(404);
228+
expect(res.response!.body.error.code).toBe('RESOURCE_NOT_FOUND');
229229
});
230230

231231
it('a system principal is still admitted: the no-service 501 answers it', async () => {
232232
process.env.OS_MCP_SERVER_ENABLED = 'true';
233233
const { kernel } = makeKernel({ withMcp: false });
234234
const d = new HttpDispatcher(kernel, undefined, { enforceProjectMembership: false });
235235
const res = await d.handleMcp({}, makeContext({ executionContext: SYSTEM }));
236-
expect(res.response.status).toBe(501);
237-
expect(res.response.body.error.code).toBe('NOT_IMPLEMENTED');
236+
expect(res.response!.status).toBe(501);
237+
expect(res.response!.body.error.code).toBe('NOT_IMPLEMENTED');
238238
});
239239

240240
it('a system principal is still admitted: MCP on and installed reaches the transport', async () => {
241241
process.env.OS_MCP_SERVER_ENABLED = 'true';
242242
const { kernel, mcpService } = makeKernel({ withMcp: true });
243243
const d = new HttpDispatcher(kernel, undefined, { enforceProjectMembership: false });
244244
const res = await d.handleMcp({ jsonrpc: '2.0', id: 1, method: 'tools/list' }, makeContext({ executionContext: SYSTEM }));
245-
expect(res.response.status).toBe(200);
245+
expect(res.response!.status).toBe(200);
246246
expect(mcpService.lastOpts).toBeDefined();
247247
});
248248
});

0 commit comments

Comments
 (0)