diff --git a/apps/sim/lib/mothership/chat/application/read-recall-chats.test.ts b/apps/sim/lib/mothership/chat/application/read-recall-chats.test.ts index e6a8af0d347..de81d1ea242 100644 --- a/apps/sim/lib/mothership/chat/application/read-recall-chats.test.ts +++ b/apps/sim/lib/mothership/chat/application/read-recall-chats.test.ts @@ -196,11 +196,15 @@ describe("a chat's other chats", () => { readRecallChats.execute({ principal: organizationPrincipal(), input }) ).rejects.toMatchObject({ code: 'forbidden' }) resetDbChainMock() - // A workflow's copilot chat is no home chat, so it reads no home chats back. + // A workflow's copilot chat is no home chat, so it reads no home chats back, and says so + // rather than reporting its own chat missing. queueWorkspaceChat('agent', 'copilot') await expect( readRecallChats.execute({ principal: workspacePrincipal(), input }) - ).rejects.toMatchObject({ code: 'not_found' }) + ).rejects.toMatchObject({ + code: 'forbidden', + message: "Reading other chats is available in home chats, not in a workflow's copilot chat", + }) resetDbChainMock() queueOrganizationChat() authBanMockFns.mockGetActivelyBannedUserIds.mockResolvedValue(['actor']) diff --git a/apps/sim/lib/mothership/chat/application/read-recall-chats.ts b/apps/sim/lib/mothership/chat/application/read-recall-chats.ts index 04f1ba9bacd..8ab8bdae7dc 100644 --- a/apps/sim/lib/mothership/chat/application/read-recall-chats.ts +++ b/apps/sim/lib/mothership/chat/application/read-recall-chats.ts @@ -100,7 +100,12 @@ export const readRecallChats = defineAuthorizedChatUseCase({ }, }, async execute({ principal, context, input }): Promise { - if (context.type !== 'mothership') throw new OrchestrationError('not_found', 'Chat not found') + if (context.type !== 'mothership') { + throw new OrchestrationError( + 'forbidden', + "Reading other chats is available in home chats, not in a workflow's copilot chat" + ) + } if (context.mode !== 'agent' && context.mode !== 'plan') { throw new OrchestrationError('forbidden', 'Reading other chats requires an agent chat') }