{"record":{"id":"f25e359e0eeddfad","repo":"Mintplex-Labs/anything-llm","slug":"workspace-not-found-f25e35","errorCode":null,"errorMessage":"Workspace not found","messagePattern":"Workspace not found","errorType":"http","errorClass":null,"httpStatus":404,"severity":"warning","filePath":"server/endpoints/browserExtension.js","lineNumber":93,"sourceCode":"        console.error(error);\n        response.status(500).json({ error: \"Failed to fetch workspaces\" });\n      }\n    }\n  );\n\n  app.post(\n    \"/browser-extension/embed-content\",\n    [validBrowserExtensionApiKey],\n    async (request, response) => {\n      try {\n        const { workspaceId, textContent, metadata } = reqBody(request);\n        const user = await userFromSession(request, response);\n        const workspace = multiUserMode(response)\n          ? await Workspace.getWithUser(user, { id: parseInt(workspaceId) })\n          : await Workspace.get({ id: parseInt(workspaceId) });\n\n        if (!workspace) {\n          response.status(404).json({ error: \"Workspace not found\" });\n          return;\n        }\n\n        const Collector = new CollectorApi();\n        const { success, reason, documents } = await Collector.processRawText(\n          textContent,\n          metadata\n        );\n\n        if (!success) {\n          response.status(500).json({ success: false, error: reason });\n          return;\n        }\n\n        const { failedToEmbed = [], errors = [] } = await Document.addDocuments(\n          workspace,\n          [documents[0].location],\n          user?.id","sourceCodeStart":75,"sourceCodeEnd":111,"githubUrl":"https://github.com/Mintplex-Labs/anything-llm/blob/3aec848f2885144aa8f1e53b9731a04310d5d558/server/endpoints/browserExtension.js#L75-L111","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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."],"exampleFix":"// before\nbody: JSON.stringify({ workspaceId: \"my-workspace\", textContent, metadata })\n// after\nconst workspaces = await listWorkspaces(apiKey); // GET /browser-extension/workspaces\nconst target = workspaces.find((w) => w.slug === \"my-workspace\");\nbody: JSON.stringify({ workspaceId: String(target.id), textContent, metadata })","handlingStrategy":"validation","validationCode":"const workspaces = await listWorkspaces(apiKey); // GET /browser-extension/workspaces\nconst target = workspaces.find((w) => String(w.id) === String(workspaceId));\nif (!target) throw new Error(`Workspace ${workspaceId} not available to this API key`);","typeGuard":"const isNumericId = (v: unknown): v is string =>\n  typeof v === 'string' && /^\\d+$/.test(v);","tryCatchPattern":"try { await embedContent(apiKey, { workspaceId, textContent, metadata }); }\ncatch (e) {\n  if (e.status === 404) { /* re-sync the workspace list and re-prompt the user */ }\n  else throw e;\n}","preventionTips":["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."],"tags":["browser-extension","workspace","http-404","invalid-id","multi-user"],"backgroundTag":"resource-not-found","analyzedSha":"3aec848f2885144aa8f1e53b9731a04310d5d558","analyzedAt":"2026-08-18T10:02:21.017Z","contentChangedAt":"2026-08-18T10:02:21.017Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}