Mintplex-Labs/anything-llm · warning · Error

Workspace not found

Error message

Workspace not found

What it means

Thrown by WorkspaceSuggestedMessages.saveAll when no workspace matches the provided slug (prisma.workspaces.findUnique by slug returns null). Reached via POST /workspace/:slug/suggested-messages. Note: this error is caught and only console.error-logged; the function returns void and the endpoint still responds 200 success, so the caller never sees the failure.

Source

Thrown at server/models/workspacesSuggestedMessages.js:35

    try {
      const messages = await prisma.workspace_suggested_messages.findMany({
        where: clause,
        take: limit || undefined,
      });
      return messages;
    } catch (error) {
      console.error(error.message);
      return [];
    }
  },

  saveAll: async function (messages, workspaceSlug) {
    try {
      const workspace = await prisma.workspaces.findUnique({
        where: { slug: workspaceSlug },
      });

      if (!workspace) throw new Error("Workspace not found");

      // Delete all existing messages for the workspace
      await prisma.workspace_suggested_messages.deleteMany({
        where: { workspaceId: workspace.id },
      });

      // Create new messages
      // We create each message individually because prisma
      // with sqlite does not support createMany()
      for (const message of messages) {
        await prisma.workspace_suggested_messages.create({
          data: {
            workspaceId: workspace.id,
            heading: message.heading,
            message: message.message,
          },
        });
      }

View on GitHub (pinned to 526360e320)

Solutions

  1. Confirm the workspace slug still exists before saving suggested messages.
  2. Add the validWorkspaceSlug middleware to this route so a bad slug is rejected with 404 instead of silently swallowed.
  3. Refresh the workspace list in the UI before editing its suggested messages.

Example fix

// before (error swallowed, endpoint returns 200)
await WorkspaceSuggestedMessages.saveAll(messages, slug);
return response.status(200).json({ success: true });
// after (surface the failure)
const workspace = await Workspace.get({ slug });
if (!workspace) return response.status(404).json({ success: false, message: 'Workspace not found' });
await WorkspaceSuggestedMessages.saveAll(messages, slug);
Defensive patterns

Strategy: validation

Validate before calling

const workspace = await prisma.workspaces.findUnique({ where: { slug: workspaceSlug } });
if (!workspace) return respond(404, 'Workspace not found');
await WorkspaceSuggestedMessages.saveAll(messages, workspaceSlug);

Prevention

When it happens

Trigger: POST /workspace/:slug/suggested-messages where the slug does not correspond to any workspace (deleted, renamed, typo, or wrong instance). The middleware validWorkspaceSlug is not on this route, so the lookup is the only guard.

Common situations: Workspace was deleted or its slug changed after the page loaded. Cross-instance slug copy. Race between workspace deletion and a lingering UI save.

Related errors


AI-assisted analysis of Mintplex-Labs/anything-llm@526360e320 (2026-08-13). Data as JSON: /api/errors/59deeb13b3437b4f. Report an issue: GitHub.