Skip to content

Commit 756ba71

Browse files
committed
fix(mothership): workspaceId is required end-to-end — no silent fallback path
Companion to the worker contract tightening. The requiredness propagates up sim's own chain: the payload builder and the workflow branch carried optional workspaceId that was never truly optional (the resolver's 'resolved' variant guarantees it; the workspace contract requires it) — now typed as it always behaved. Regenerated protocol mirror. Claude-Session: https://claude.ai/code/session_01CgaxNAaeD3taGdghbXn17w
1 parent 53886b1 commit 756ba71

3 files changed

Lines changed: 13 additions & 5 deletions

File tree

apps/sim/lib/mothership/chat/payload.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,10 @@ interface BuildPayloadParams {
3535
message: string
3636
workflowId?: string
3737
workflowName?: string
38-
workspaceId?: string
38+
/** Required by the wire contract: both branches resolve it before building (the
39+
* workspace-scoped contract requires it; the workflow branch derives it from the
40+
* workflow). A missing value used to make the worker fabricate a random identity. */
41+
workspaceId: string
3942
userId: string
4043
userMessageId: string
4144
mode: string
@@ -420,7 +423,7 @@ export async function buildCopilotRequestPayload(
420423
userId,
421424
messageId: userMessageId,
422425
...(chatId ? { chatId } : {}),
423-
...(params.workspaceId ? { workspaceId: params.workspaceId } : {}),
426+
workspaceId: params.workspaceId,
424427
...(workflowId ? { workflowId } : {}),
425428
...(allContexts.length > 0 ? { context: allContexts } : {}),
426429
...(integrationTools.length > 0 ? { integrationTools } : {}),

apps/sim/lib/mothership/chat/post.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -333,7 +333,9 @@ type UnifiedChatBranch =
333333
kind: 'workflow'
334334
workflowId: string
335335
workflowName?: string
336-
workspaceId?: string
336+
/** Always present: the resolver's 'resolved' variant guarantees it (the workflow's
337+
* own workspace) — the wire contract requires it. */
338+
workspaceId: string
337339
effectiveModel: string
338340
selectedModel: string
339341
mode: UnifiedChatRequest['mode']
@@ -355,7 +357,7 @@ type UnifiedChatBranch =
355357
effort?: 'low' | 'medium' | 'high' | 'xhigh' | 'max'
356358
workflowId: string
357359
workflowName?: string
358-
workspaceId?: string
360+
workspaceId: string
359361
mode: UnifiedChatRequest['mode']
360362
provider?: string
361363
commands?: string[]

apps/sim/lib/mothership/generated/protocol.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,10 @@ export interface ChatRequest {
2525
protocolVersion?: number | undefined;
2626
messageId?: string | undefined;
2727
chatId?: string | undefined;
28-
workspaceId?: string | undefined;
28+
/** Required: memories, analytics, and the chat row all key on it — sim always resolves
29+
* it (workspace-scoped directly; workflow-scoped from the workflow). A missing value
30+
* used to FABRICATE a random workspace identity per request. */
31+
workspaceId: string;
2932
/** Workflow-scoped chats (the workflow-page copilot): the agent anchors to this workflow. */
3033
workflowId?: string | undefined;
3134
/** Connected-service operation schemas served by the integration gateway. */

0 commit comments

Comments
 (0)