Mintplex-Labs/anything-llm · error · Error

res.statusText

Error message

res.statusText

What it means

Thrown by deleteEmbed in the AnythingLLM frontend when DELETE /api/embed/:embedId responds with a non-2xx status; the message is the HTTP status text ('Not Found', 'Unauthorized', ...). Critically, the .catch returns { success: true, error: e.message } — the success:true is a bug: a failed deletion is reported as successful to any caller that only checks the success flag.

Solutions

  1. Do not trust the `success` flag alone — also check the `error` field, which is populated even when success is true.
  2. Refresh the embed list before deleting so the embedId points at an embed that still exists.
  3. If the status is 401/403, re-login or fix permissions, then retry the delete.
  4. Fix the bug in the catch block: return { success: false, ... } so the flag matches reality.

Example fix

// before (frontend/src/models/embed.js)
.catch((e) => {
  console.error(e);
  return { success: true, error: e.message }; // failed delete reported as success
});

// after
.catch((e) => {
  console.error(e);
  return { success: false, error: e.message }; // flag now matches the outcome
});
Defensive patterns

Strategy: try-catch

Validate before calling

// run before deleteEmbed
if (!embedId || !/^[0-9a-f-]{36}$/i.test(embedId)) {
  throw new Error('Invalid embed id');
}

Type guard

/** @param {any} r @returns {r is {success: boolean, error: string|null}} */
function isEmbedResult(r) {
  return typeof r === 'object' && r !== null && typeof r.success === 'boolean';
}
// NOTE: until the success:true-in-catch bug is fixed, check `error` too:
function embedDeleted(r) { return isEmbedResult(r) && r.success === true && !r.error; }

Try / catch

const result = await Embed.deleteEmbed(embedId);
if (!embedDeleted(result)) {
  // result.error holds the statusText ('Not Found', 'Unauthorized')
  showUserError('Could not delete embed', result.error);
  return false;
}

Prevention

When it happens

Trigger: Deleting an embed whose UUID no longer exists (404 → 'Not Found'); passing a malformed embedId; calling with an expired or missing auth token (401 'Unauthorized'); an account without permission for that embed (403). In every case the throw happens on !res.ok and the catch then (wrongly) marks it successful.

Common situations: Embed already deleted from another tab or by another admin, leaving a stale list entry; workspace removed which cascaded to its embeds; session token expired after a long idle period before the delete was clicked.

Understand the failure class

Background: 'Something went wrong' / 'Request failed (500)' / 'HTTP error! status: 404' — what failed HTTP requests actually mean and how to find the real cause — this error's family across 28 libraries.

Related errors


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

Appendix: source

Thrown at frontend/src/models/embed.js:48

    return await fetch(`${API_BASE}/embed/update/${embedId}`, {
      method: "POST",
      headers: baseHeaders(),
      body: JSON.stringify(data),
    })
      .then((res) => res.json())
      .catch((e) => {
        console.error(e);
        return { success: false, error: e.message };
      });
  },
  deleteEmbed: async (embedId) => {
    return await fetch(`${API_BASE}/embed/${embedId}`, {
      method: "DELETE",
      headers: baseHeaders(),
    })
      .then((res) => {
        if (res.ok) return { success: true, error: null };
        throw new Error(res.statusText);
      })
      .catch((e) => {
        console.error(e);
        return { success: true, error: e.message };
      });
  },
  chats: async (offset = 0) => {
    return await fetch(`${API_BASE}/embed/chats`, {
      method: "POST",
      headers: baseHeaders(),
      body: JSON.stringify({ offset }),
    })
      .then((res) => res.json())
      .catch((e) => {
        console.error(e);
        return [];
      });
  },

View on GitHub (pinned to 3aec848f28)