Mintplex-Labs/anything-llm · error

Workspace not found

Error message

Workspace not found

What it means

Handling of the 'workspace-content' command in server/endpoints/mobile/utils/index.js: it resolves the workspace by body.workspaceSlug via Workspace.getWithUser(user, { slug }) in multi-user mode (which also enforces the user's access) or Workspace.get({ slug }) otherwise. When nothing matches it returns 400 { error: 'Workspace not found' } (note: 400, not 404). The command returns the workspace's threads and chats.

Solutions

  1. Use the slug exactly as returned by the earlier 'workspaces' command for the same user
  2. Always include workspaceSlug in the body — its absence yields this same error
  3. If permissions may have changed, re-run the 'workspaces' command to see what is still visible

Example fix

// before
api.command({ command: 'workspace-content', slug });

// after
api.command({ command: 'workspace-content', workspaceSlug: slug });
Defensive patterns

Strategy: validation

Validate before calling

const res = await api.command({ command: 'workspaces' });
const slugs = new Set(res.workspaces.map((w) => w.slug));
if (!slugs.has(targetSlug)) throw new Error(`Unknown workspace slug: ${targetSlug}`);

Type guard

/** @param {any} b */
function isWorkspaceCommand(b) {
  return typeof b?.workspaceSlug === 'string' && b.workspaceSlug.length > 0;
}

Prevention

When it happens

Trigger: POSTing command 'workspace-content' with a slug that doesn't exist, is misspelled, or that the device's user can't access; or omitting workspaceSlug entirely — String(undefined) becomes 'undefined', which matches no slug, so a missing field masquerades as not-found.

Common situations: Slug copied from a URL with different casing/encoding; workspace deleted between the list call and the content call; user's workspace permissions changed; client forgets to include the field.

Understand the failure class

Background: 'Could not be found', 'does not exist', 'not found in database': the resource-not-found family when an ID, slug, key, or URI lookup comes back empty — this error's family across 20 libraries.

Related errors


AI-assisted analysis of Mintplex-Labs/anything-llm@20f6d3546c (2026-08-18). Data as JSON: /api/errors/ecede2d20d7e5242. Report an issue: GitHub.

Appendix: source

Thrown at server/endpoints/mobile/utils/index.js:54

            include: true,
            ...(user ? { user_id: user.id } : {}),
          },
        }),
      ]);
      workspace.threadCount = threadCount;
      workspace.chatCount = chatCount;
      workspace.platform = MobileDevice.platform;
    }
    return response.status(200).json({ workspaces });
  }

  if (command === "workspace-content") {
    const workspace = user
      ? await Workspace.getWithUser(user, { slug: String(body.workspaceSlug) })
      : await Workspace.get({ slug: String(body.workspaceSlug) });

    if (!workspace)
      return response.status(400).json({ error: "Workspace not found" });
    const threads = [
      {
        id: 0,
        name: "Default Thread",
        slug: "default-thread",
        workspace_id: workspace.id,
        createdAt: new Date(),
        lastUpdatedAt: new Date(),
      },
      ...(await prisma.workspace_threads.findMany({
        where: {
          workspace_id: workspace.id,
          ...(user ? { user_id: user.id } : {}),
        },
      })),
    ];
    const chats = (
      await prisma.workspace_chats.findMany({

View on GitHub (pinned to 20f6d3546c)