{"record":{"id":"f7d62acd6165bf29","repo":"Mintplex-Labs/anything-llm","slug":"not-found","errorCode":null,"errorMessage":"Not Found","messagePattern":"Not Found","errorType":"http","errorClass":null,"httpStatus":404,"severity":"warning","filePath":"server/endpoints/admin.js","lineNumber":308,"sourceCode":"        response.sendStatus(500).end();\n      }\n    }\n  );\n\n  app.delete(\n    \"/admin/workspaces/:id\",\n    [\n      validatedRequest,\n      strictMultiUserRoleValid([ROLES.admin, ROLES.manager]),\n      workspaceDeletionProtection,\n    ],\n    async (request, response) => {\n      try {\n        const { id } = request.params;\n        const VectorDb = getVectorDbClass();\n        const workspace = await Workspace.get({ id: Number(id) });\n        if (!workspace) {\n          response.sendStatus(404).end();\n          return;\n        }\n\n        await WorkspaceChats.delete({ workspaceId: Number(workspace.id) });\n        await DocumentVectors.deleteForWorkspace(Number(workspace.id));\n        await Document.delete({ workspaceId: Number(workspace.id) });\n        await Workspace.delete({ id: Number(workspace.id) });\n        try {\n          await VectorDb[\"delete-namespace\"]({ namespace: workspace.slug });\n        } catch (e) {\n          console.error(e.message);\n        }\n\n        response.status(200).json({ success: true, error: null });\n      } catch (e) {\n        console.error(e);\n        response.sendStatus(500).end();\n      }","sourceCodeStart":290,"sourceCodeEnd":326,"githubUrl":"https://github.com/Mintplex-Labs/anything-llm/blob/526360e320da9d1b36074be5ed64fe76e5bbfbbd/server/endpoints/admin.js#L290-L326","documentation":"DELETE /admin/workspaces/:id (server/endpoints/admin.js:295) returns HTTP 404 via response.sendStatus(404).end() at line 308 when Workspace.get({ id: Number(id) }) returns a falsy workspace. This is an explicit, intentional guard — not an exception — fired when the workspace row for the given id does not exist.","triggerScenarios":"DELETE /admin/workspaces/999 where workspace 999 does not exist; the workspace was already deleted in another session; :id is a numeric-looking string that Number() coerces to a value with no matching row (including NaN, since Number('abc')=NaN and no workspace has id NaN).","commonSituations":"Stale admin UI still showing a workspace tile that has been removed; double-click on the delete button causing the second request to find nothing; an automated cleanup script running concurrently.","solutions":["Treat 404 as success if the user's intent was 'make sure it's gone' (idempotent delete).","Refresh the workspace list in the UI before issuing the delete to avoid stale ids.","If the front-end shows an error toast on 404, suppress it specifically for delete operations.","Confirm :id is the numeric primary key and not the workspace slug — the lookup uses id, not slug."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"const ws = await Workspace.get({ id: Number(id) });\nif (!ws) {\n  // expected when caller asks to delete something already gone\n  return response.sendStatus(404).end();\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Treat 404 on delete as idempotent success when the goal is 'ensure it is gone'.","Refresh the workspace list in the UI before deleting to avoid stale ids.","Suppress 404 error toasts in the client for delete operations specifically."],"tags":["express","admin-api","workspaces","not-found","idempotency"],"backgroundTag":null,"analyzedSha":"526360e320da9d1b36074be5ed64fe76e5bbfbbd","analyzedAt":"2026-08-13T01:45:47.170Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}