Mintplex-Labs/anything-llm · warning
Workspace not found
Error message
Workspace not found
What it means
Deliberate 404 from POST /browser-extension/embed-content when Workspace.get/getWithUser returns null for the requested id. Because workspaceId goes through parseInt, any non-numeric value ('default', 'my-space', '') becomes NaN and never matches a row, producing the same 404. In multi-user mode the lookup is scoped with getWithUser(user, ...), so a real workspace owned by a different user also 404s.
Source
Thrown at server/endpoints/browserExtension.js:93
console.error(error);
response.status(500).json({ error: "Failed to fetch workspaces" });
}
}
);
app.post(
"/browser-extension/embed-content",
[validBrowserExtensionApiKey],
async (request, response) => {
try {
const { workspaceId, textContent, metadata } = reqBody(request);
const user = await userFromSession(request, response);
const workspace = multiUserMode(response)
? await Workspace.getWithUser(user, { id: parseInt(workspaceId) })
: await Workspace.get({ id: parseInt(workspaceId) });
if (!workspace) {
response.status(404).json({ error: "Workspace not found" });
return;
}
const Collector = new CollectorApi();
const { success, reason, documents } = await Collector.processRawText(
textContent,
metadata
);
if (!success) {
response.status(500).json({ success: false, error: reason });
return;
}
const { failedToEmbed = [], errors = [] } = await Document.addDocuments(
workspace,
[documents[0].location],
user?.idView on GitHub (pinned to 3aec848f28)
Solutions
- Call GET /browser-extension/workspaces with the same API key and use an id from that live list (send it as a digit string, not the slug).
- Confirm workspaceId is present in the JSON body and is numeric (e.g. "2", not "my-workspace").
- In multi-user mode, use an API key created by (or shared with) the workspace owner.
Example fix
// before
body: JSON.stringify({ workspaceId: "my-workspace", textContent, metadata })
// after
const workspaces = await listWorkspaces(apiKey); // GET /browser-extension/workspaces
const target = workspaces.find((w) => w.slug === "my-workspace");
body: JSON.stringify({ workspaceId: String(target.id), textContent, metadata }) Defensive patterns
Strategy: validation
Validate before calling
const workspaces = await listWorkspaces(apiKey); // GET /browser-extension/workspaces
const target = workspaces.find((w) => String(w.id) === String(workspaceId));
if (!target) throw new Error(`Workspace ${workspaceId} not available to this API key`); Type guard
const isNumericId = (v: unknown): v is string => typeof v === 'string' && /^\d+$/.test(v);
Try / catch
try { await embedContent(apiKey, { workspaceId, textContent, metadata }); }
catch (e) {
if (e.status === 404) { /* re-sync the workspace list and re-prompt the user */ }
else throw e;
} Prevention
- Always resolve the numeric id from the live workspace list instead of caching or hard-coding it.
- Never substitute a slug or name for the numeric id.
- In multi-user mode, use a key owned by the workspace owner.
When it happens
Trigger: Posting a workspace slug or name instead of the numeric id; using an id from a stale workspace list after the workspace (or whole DB) was deleted; multi-user mode where the API key's user does not own the target workspace; workspaceId missing from the body so parseInt(undefined) is NaN.
Common situations: Hard-coded workspace id in an extension config after a DB reset; extension cached the first workspace list it ever fetched; server switched from single-user to multi-user so ownership scoping suddenly applies.
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
- File not found or access denied
- Image not found or access denied
- Unauthorized
- Memory not found.
- Failed to create workspace
AI-assisted analysis of Mintplex-Labs/anything-llm@3aec848f28 (2026-08-18).
Data as JSON: /api/errors/f25e359e0eeddfad.
Report an issue: GitHub.