{"record":{"id":"ecede2d20d7e5242","repo":"Mintplex-Labs/anything-llm","slug":"workspace-not-found-ecede2","errorCode":null,"errorMessage":"Workspace not found","messagePattern":"Workspace not found","errorType":"http","errorClass":null,"httpStatus":400,"severity":"error","filePath":"server/endpoints/mobile/utils/index.js","lineNumber":54,"sourceCode":"            include: true,\n            ...(user ? { user_id: user.id } : {}),\n          },\n        }),\n      ]);\n      workspace.threadCount = threadCount;\n      workspace.chatCount = chatCount;\n      workspace.platform = MobileDevice.platform;\n    }\n    return response.status(200).json({ workspaces });\n  }\n\n  if (command === \"workspace-content\") {\n    const workspace = user\n      ? await Workspace.getWithUser(user, { slug: String(body.workspaceSlug) })\n      : await Workspace.get({ slug: String(body.workspaceSlug) });\n\n    if (!workspace)\n      return response.status(400).json({ error: \"Workspace not found\" });\n    const threads = [\n      {\n        id: 0,\n        name: \"Default Thread\",\n        slug: \"default-thread\",\n        workspace_id: workspace.id,\n        createdAt: new Date(),\n        lastUpdatedAt: new Date(),\n      },\n      ...(await prisma.workspace_threads.findMany({\n        where: {\n          workspace_id: workspace.id,\n          ...(user ? { user_id: user.id } : {}),\n        },\n      })),\n    ];\n    const chats = (\n      await prisma.workspace_chats.findMany({","sourceCodeStart":36,"sourceCodeEnd":72,"githubUrl":"https://github.com/Mintplex-Labs/anything-llm/blob/3aec848f2885144aa8f1e53b9731a04310d5d558/server/endpoints/mobile/utils/index.js#L36-L72","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Use the slug exactly as returned by the earlier 'workspaces' command for the same user","Always include workspaceSlug in the body — its absence yields this same error","If permissions may have changed, re-run the 'workspaces' command to see what is still visible"],"exampleFix":"// before\napi.command({ command: 'workspace-content', slug });\n\n// after\napi.command({ command: 'workspace-content', workspaceSlug: slug });","handlingStrategy":"validation","validationCode":"const res = await api.command({ command: 'workspaces' });\nconst slugs = new Set(res.workspaces.map((w) => w.slug));\nif (!slugs.has(targetSlug)) throw new Error(`Unknown workspace slug: ${targetSlug}`);","typeGuard":"/** @param {any} b */\nfunction isWorkspaceCommand(b) {\n  return typeof b?.workspaceSlug === 'string' && b.workspaceSlug.length > 0;\n}","tryCatchPattern":null,"preventionTips":["Always take slugs from the 'workspaces' command response, never hand-typed","Include workspaceSlug in every workspace-scoped command body","Refresh the workspace list when content fetches start failing"],"tags":["mobile","workspace","slug","not-found","request-body"],"backgroundTag":"resource-not-found","analyzedSha":"3aec848f2885144aa8f1e53b9731a04310d5d558","analyzedAt":"2026-08-18T10:02:21.017Z","schemaVersion":2},"datasetVersion":"2026-08-23T16:17:53.355Z"}