Skip to content

Commit 3b2fa28

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 2370cf8 commit 3b2fa28

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
@@ -424,7 +427,7 @@ export async function buildCopilotRequestPayload(
424427
userId,
425428
messageId: userMessageId,
426429
...(chatId ? { chatId } : {}),
427-
...(params.workspaceId ? { workspaceId: params.workspaceId } : {}),
430+
workspaceId: params.workspaceId,
428431
...(workflowId ? { workflowId } : {}),
429432
...(allContexts.length > 0 ? { context: allContexts } : {}),
430433
...(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
@@ -337,7 +337,9 @@ type UnifiedChatBranch =
337337
kind: 'workflow'
338338
workflowId: string
339339
workflowName?: string
340-
workspaceId?: string
340+
/** Always present: the resolver's 'resolved' variant guarantees it (the workflow's
341+
* own workspace) — the wire contract requires it. */
342+
workspaceId: string
341343
effectiveModel: string
342344
selectedModel: string
343345
mode: UnifiedChatRequest['mode']
@@ -359,7 +361,7 @@ type UnifiedChatBranch =
359361
effort?: 'low' | 'medium' | 'high' | 'xhigh' | 'max'
360362
workflowId: string
361363
workflowName?: string
362-
workspaceId?: string
364+
workspaceId: string
363365
mode: UnifiedChatRequest['mode']
364366
provider?: string
365367
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)