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
- Do not trust the `success` flag alone — also check the `error` field, which is populated even when success is true.
- Refresh the embed list before deleting so the embedId points at an embed that still exists.
- If the status is 401/403, re-login or fix permissions, then retry the delete.
- 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
- Until the catch bug is fixed, never branch on `success` alone — also check the `error` field.
- Refresh the embed list before deleting to avoid 404s on stale ids.
- Wrap embed-management flows so a failed delete keeps the row visible instead of optimistically removing it.
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
- Error removing logo!
- Failed to remove pfp.
- Rate limit exceeded
- This chat has been disabled by the administrator - try…
- Bad Request
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)