Mintplex-Labs/anything-llm · error

threadError

Error message

threadError

What it means

Propagation guard in the thread-fork endpoint: WorkspaceThread.new returned a non-null message, meaning thread creation itself failed (e.g. DB constraint or slug collision), and that creation error is relayed to the client.

Source

Thrown at server/endpoints/workspaces.js:718

            )?.id ?? null
          : null;
        const chatsToFork = await WorkspaceChats.where(
          {
            workspaceId: workspace.id,
            user_id: user?.id,
            include: true, // only duplicate visible chats
            thread_id: threadId,
            api_session_id: null, // Do not include API session chats.
            id: { lte: Number(chatId) },
          },
          null,
          { id: "asc" }
        );

        const { thread: newThread, message: threadError } =
          await WorkspaceThread.new(workspace, user?.id);
        if (threadError)
          return response.status(500).json({ error: threadError });

        let lastMessageText = "";
        const chatsData = chatsToFork.map((chat) => {
          const chatResponse = safeJsonParse(chat.response, {});
          if (chatResponse?.text)
            lastMessageText = stripThinkingFromText(chatResponse.text);

          return {
            workspaceId: workspace.id,
            prompt: chat.prompt,
            response: JSON.stringify(chatResponse),
            user_id: user?.id,
            thread_id: newThread.id,
          };
        });
        await WorkspaceChats.bulkCreate(chatsData);
        await WorkspaceThread.update(newThread, {
          name: !!lastMessageText

View on GitHub (pinned to 3aec848f28)

Solutions

  1. Inspect the threadError value for the underlying cause.
  2. Verify the thread exists and the message payload is valid, then retry.
Defensive patterns

Strategy: try-catch

When it happens

Trigger: Thrown at server/endpoints/workspaces.js:718 when the library encounters an invalid state.

Common situations: Chat execution failed and the thread returned an error.


AI-assisted analysis of Mintplex-Labs/anything-llm@3aec848f28 (2026-08-18). Data as JSON: /api/errors/0507c79a8fbf8e76. Report an issue: GitHub.