{"record":{"id":"65a69efc4009f97f","repo":"Mintplex-Labs/anything-llm","slug":"invite-not-found-or-already-disabled","errorCode":null,"errorMessage":"Invite not found or already disabled","messagePattern":"Invite not found or already disabled","errorType":"http","errorClass":null,"httpStatus":404,"severity":"warning","filePath":"server/endpoints/api/admin/index.js","lineNumber":426,"sourceCode":"    */\n      try {\n        if (!multiUserMode(response)) {\n          response.sendStatus(401).end();\n          return;\n        }\n\n        const { id } = request.params;\n        const parsedId = Number(id);\n        if (isNaN(parsedId)) {\n          response\n            .status(400)\n            .json({ success: false, error: \"Invalid invite id\" });\n          return;\n        }\n\n        const { success, error } = await Invite.deactivate(parsedId);\n        if (!success) {\n          response.status(404).json({\n            success: false,\n            error: \"Invite not found or already disabled\",\n          });\n          return;\n        }\n\n        response.status(200).json({ success, error });\n      } catch (e) {\n        console.error(e);\n        response.sendStatus(500).end();\n      }\n    }\n  );\n\n  app.get(\n    \"/v1/admin/workspaces/:workspaceId/users\",\n    [validApiKey],\n    async (request, response) => {","sourceCodeStart":408,"sourceCodeEnd":444,"githubUrl":"https://github.com/Mintplex-Labs/anything-llm/blob/3aec848f2885144aa8f1e53b9731a04310d5d558/server/endpoints/api/admin/index.js#L408-L444","documentation":"Returned (404) when Invite.deactivate(parsedId) reports failure. In server/models/invite.js:26, deactivate does prisma.findUnique on the id and returns {success:false,'Invite not found'} only when no row matches — note it does NOT check status, so an already-disabled invite still 'succeeds' (200); the 'already disabled' wording is misleading. Genuine DB errors during update also map here via the catch.","triggerScenarios":"Deactivating an id that does not exist (deleted invite, wrong instance DB, id from another environment); a Prisma failure during the update (DB down, constraint issue).","commonSituations":"Idempotent retry scripts calling deactivate twice where the row was hard-deleted; pointing scripts at the wrong environment's DB; invites removed by cleanup jobs.","solutions":["List invites via the admin API first, confirm the id exists, then deactivate","Treat this 404 as success in idempotent automation when the invite is simply gone","If it persists for a known-existing id, check Prisma/DB connectivity — deactivate's catch logs the real error server-side"],"exampleFix":null,"handlingStrategy":"validation","validationCode":"async function deactivateInviteSafely(id) {\n  const res = await fetch('/api/v1/admin/invites');\n  const invites = await res.json();\n  if (!invites.some(i => i.id === Number(id))) return { skipped: 'not present' };\n  return fetch(`/api/v1/admin/invite/deactivate/${id}`, { method: 'POST' });\n}","typeGuard":null,"tryCatchPattern":"try {\n  const res = await fetch(`/api/v1/admin/invite/deactivate/${id}`, { method:'POST' });\n  if (res.status === 404) return { ok: true, note: 'invite already gone' }; // idempotent success\n  if (res.status === 400) throw new Error('bad invite id');\n  if (!res.ok) throw new Error(`HTTP ${res.status}`);\n} catch (err) { console.error('deactivate failed:', err.message); }","preventionTips":["Treat 404 as idempotent success in automation since the end state (invite disabled/gone) is achieved","Fetch the invite list first and confirm the row exists","Remember an already-disabled invite returns 200 — the 'already disabled' wording overstates this branch"],"tags":["admin-api","invites","http-404","idempotency"],"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"}