Skip to content

Commit 75e711a

Browse files
committed
fix(mothership): answer a chat for an unreachable workspace with 404, as the workspace routes do
1 parent 9310074 commit 75e711a

2 files changed

Lines changed: 8 additions & 7 deletions

File tree

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

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,11 @@ import { CopilotTransport } from '@/lib/mothership/generated/trace-attribute-val
7272
import { TraceAttr } from '@/lib/mothership/generated/trace-attributes-v1'
7373
import { TraceSpan } from '@/lib/mothership/generated/trace-spans-v1'
7474
import { resolveMothershipModelSettings } from '@/lib/mothership/model-options'
75-
import { createBadRequestResponse, createUnauthorizedResponse } from '@/lib/mothership/request/http'
75+
import {
76+
createBadRequestResponse,
77+
createNotFoundResponse,
78+
createUnauthorizedResponse,
79+
} from '@/lib/mothership/request/http'
7680
import { durableResourceAuthoringVersion } from '@/lib/mothership/request/lifecycle/recovery-config'
7781
import { createSSEStream, SSE_RESPONSE_HEADERS } from '@/lib/mothership/request/lifecycle/start'
7882
import { startCopilotOtelRoot, withCopilotSpan } from '@/lib/mothership/request/otel'
@@ -643,7 +647,7 @@ async function resolveBranch(params: {
643647
)
644648

645649
if (workspacePermission === null) {
646-
return createBadRequestResponse('Workspace not found or access denied')
650+
return createNotFoundResponse('Workspace not found or access denied')
647651
}
648652

649653
return {

‎apps/sim/scripts/test-browser-extension-e2e.ts‎

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2334,11 +2334,8 @@ try {
23342334
await composer.fill('QA scoped follow-up')
23352335
await composer.press('Enter')
23362336
const refusal = (await followUp).status()
2337-
// The chat route answers a workspace the sender cannot reach with 400, before any run.
2338-
assert(
2339-
refusal === 400 || refusal === 403 || refusal === 404,
2340-
`The follow-up was answered ${refusal}`
2341-
)
2337+
// A workspace the sender cannot reach is not found to them, answered before any run.
2338+
assert.equal(refusal, 404, `The follow-up was answered ${refusal}`)
23422339
// Refused, not re-scoped: no run under the organization, and the chat keeps its workspace.
23432340
assert.deepEqual(await runs(), [{ workspaceId: scopedWorkspaceId, organizationId: null }])
23442341
const [chat] = await sql<{ workspaceId: string | null; organizationId: string | null }[]>`

0 commit comments

Comments
 (0)