Mintplex-Labs/anything-llm · warning

Invite not found or already disabled

Error message

Invite not found or already disabled

What it means

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.

Source

Thrown at server/endpoints/api/admin/index.js:426

    */
      try {
        if (!multiUserMode(response)) {
          response.sendStatus(401).end();
          return;
        }

        const { id } = request.params;
        const parsedId = Number(id);
        if (isNaN(parsedId)) {
          response
            .status(400)
            .json({ success: false, error: "Invalid invite id" });
          return;
        }

        const { success, error } = await Invite.deactivate(parsedId);
        if (!success) {
          response.status(404).json({
            success: false,
            error: "Invite not found or already disabled",
          });
          return;
        }

        response.status(200).json({ success, error });
      } catch (e) {
        console.error(e);
        response.sendStatus(500).end();
      }
    }
  );

  app.get(
    "/v1/admin/workspaces/:workspaceId/users",
    [validApiKey],
    async (request, response) => {

View on GitHub (pinned to 3aec848f28)

Solutions

  1. List invites via the admin API first, confirm the id exists, then deactivate
  2. Treat this 404 as success in idempotent automation when the invite is simply gone
  3. If it persists for a known-existing id, check Prisma/DB connectivity — deactivate's catch logs the real error server-side
Defensive patterns

Strategy: validation

Validate before calling

async function deactivateInviteSafely(id) {
  const res = await fetch('/api/v1/admin/invites');
  const invites = await res.json();
  if (!invites.some(i => i.id === Number(id))) return { skipped: 'not present' };
  return fetch(`/api/v1/admin/invite/deactivate/${id}`, { method: 'POST' });
}

Try / catch

try {
  const res = await fetch(`/api/v1/admin/invite/deactivate/${id}`, { method:'POST' });
  if (res.status === 404) return { ok: true, note: 'invite already gone' }; // idempotent success
  if (res.status === 400) throw new Error('bad invite id');
  if (!res.ok) throw new Error(`HTTP ${res.status}`);
} catch (err) { console.error('deactivate failed:', err.message); }

Prevention

When it happens

Trigger: 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).

Common situations: 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.

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


AI-assisted analysis of Mintplex-Labs/anything-llm@3aec848f28 (2026-08-18). Data as JSON: /api/errors/65a69efc4009f97f. Report an issue: GitHub.