fix(server): allow long thread IDs in HTTP routes (#8898)
This commit is contained in:
1 parent
f8e4accf27
commit
41adccc83e
2 files changed
+44
-1
No files matched your search
@@ -103,7 +103,7 @@ const collectQueueUntil = Effect.fn("TransferBudget.collectQueueUntil")(function
|
||||
|
||||
import * as BackgroundPolicy from "./background/BackgroundPolicy.ts";
|
||||
import * as ServerConfig from "./config.ts";
|
||||
import { makeRoutesLayer } from "./server.ts";
|
||||
import { HTTP_ROUTER_CONFIG, makeRoutesLayer } from "./server.ts";
|
||||
import {
|
||||
isThreadDetailEvent,
|
||||
resolveAvailableEditorsForConfig,
|
||||
@@ -629,6 +629,7 @@ const buildAppUnderTest = (options?: {
|
||||
{
|
||||
disableListenLog: true,
|
||||
disableLogger: true,
|
||||
routerConfig: HTTP_ROUTER_CONFIG,
|
||||
},
|
||||
).pipe(
|
||||
Layer.provide(
|
||||
@@ -1527,6 +1528,41 @@ it.layer(NodeServices.layer)("server router seam", (it) => {
|
||||
}).pipe(Effect.provide(NodeHttpServer.layerTest)),
|
||||
);
|
||||
|
||||
it.effect("serves snapshots for MCP handoff thread IDs above the router default", () =>
|
||||
Effect.gen(function* () {
|
||||
const threadId = ThreadId.make(
|
||||
"thread:mcp:abfba0d2-b591-4b7e-aad1-e943d89811fa:handoff%3A0ae5edf4-2ea3-4ee3-ba7c-48de3ac92896%3A2026-08-24T17%3A08%3A52.138Z:0",
|
||||
);
|
||||
const thread = {
|
||||
...makeDefaultOrchestrationReadModel().threads[0]!,
|
||||
id: threadId,
|
||||
};
|
||||
yield* buildAppUnderTest({
|
||||
layers: {
|
||||
projectionSnapshotQuery: {
|
||||
getThreadDetailSnapshot: (requestedThreadId) =>
|
||||
Effect.succeed(
|
||||
requestedThreadId === threadId
|
||||
? Option.some({ snapshotSequence: 1, thread })
|
||||
: Option.none(),
|
||||
),
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
const response = yield* fetchEffect(
|
||||
yield* getHttpServerUrl(`/api/orchestration/threads/${encodeURIComponent(threadId)}`),
|
||||
{ headers: { cookie: yield* getAuthenticatedSessionCookieHeader() } },
|
||||
);
|
||||
const snapshot = yield* responseJsonEffect<{
|
||||
readonly thread: { readonly id: ThreadId };
|
||||
}>(response);
|
||||
|
||||
assert.equal(response.status, 200);
|
||||
assert.equal(snapshot.thread.id, threadId);
|
||||
}).pipe(Effect.provide(NodeHttpServer.layerTest)),
|
||||
);
|
||||
|
||||
it.effect("compresses large JSON responses through the composed routes", () =>
|
||||
Effect.gen(function* () {
|
||||
const descriptor = {
|
||||
|
||||
@@ -123,6 +123,12 @@ import * as RelayClient from "@t3tools/shared/relayClient";
|
||||
import { disableTailscaleServe, ensureTailscaleServe } from "@t3tools/tailscale";
|
||||
import { forkParked, ServerActivation } from "./serverActivation.ts";
|
||||
|
||||
// MCP handoff thread IDs include escaped provenance and can exceed find-my-way's
|
||||
// 100-character default for one path segment.
|
||||
export const HTTP_ROUTER_CONFIG = {
|
||||
maxParamLength: 512,
|
||||
} as const;
|
||||
|
||||
// Effect's default preemptive shutdown waits 20s before finalizing request scopes.
|
||||
// T3's primary transport is long-lived WebSocket RPC, whose Effect scope finalizer
|
||||
// already closes the websocket gracefully. Do not add an artificial drain before
|
||||
@@ -675,6 +681,7 @@ export const makeServerLayer = Layer.unwrap(
|
||||
|
||||
const routesLayer = HttpRouter.serve(makeRoutesLayer.pipe(Layer.provide(launcherLayer)), {
|
||||
disableLogger: !config.logWebSocketEvents,
|
||||
routerConfig: HTTP_ROUTER_CONFIG,
|
||||
}).pipe(Layer.tap(() => Deferred.succeed(routesReady, undefined).pipe(Effect.orDie)));
|
||||
const serverApplicationLayer = Layer.mergeAll(
|
||||
routesLayer,
|
||||
|
||||
Reference in new issue
Block a user