Mintplex-Labs/anything-llm · error · Error
res.statusText
Error message
res.statusText
What it means
Thrown by deleteEmbed when the DELETE to /embed/:embedId returns a non-OK status; the thrown message is the HTTP statusText (e.g. 'Not Found', 'Unauthorized'). Critically, the .catch returns {success: true, error: e.message} - the success:true is a defect, so callers that branch on .success will treat a failed delete as successful and silently leak embeds. Treat both the error field and the success flag with suspicion here.
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 526360e320)
Solutions
- Do NOT trust result.success alone - also check result.error before considering the delete done.
- If statusText is 'Not Found', refresh the embed list and remove the stale row.
- If 'Unauthorized'/'Forbidden', re-authenticate or surface a permissions message.
- Patch the model: the catch should return {success:false, error:e.message}.
Example fix
// before (bug: returns success:true on failure)
.catch((e) => {
console.error(e);
return { success: true, error: e.message };
});
// after
catch((e) => {
console.error(e);
return { success: false, error: e.message };
});
// caller-side guard until the model is fixed:
const res = await Embed.deleteEmbed(id);
const deleted = res.success && !res.error; Defensive patterns
Strategy: type-guard
Validate before calling
function validateEmbedId(id) {
if (!id || typeof id !== 'string') return 'embedId is required';
return null;
} Type guard
// Until the model bug (success:true on failure) is fixed, guard on BOTH fields:
/** @param {{success:boolean, error:string|null}} r */
function deleteSucceeded(r) {
return r.success === true && !r.error;
} Try / catch
const res = await Embed.deleteEmbed(embedId);
if (!deleteSucceeded(res)) {
// res.error carries statusText, e.g. 'Not Found' or 'Unauthorized'
handleDeleteFailure(res.error);
} Prevention
- Do NOT trust result.success alone - the model returns success:true on failure (bug).
- Patch the model's .catch to return { success:false, error:e.message }.
- Handle 404 specially: the embed may already be gone (idempotent delete).
- Re-authenticate on 401/403 statusText.
When it happens
Trigger: embedId does not exist (404 Not Found); caller's session lacks permission to delete this embed (401/403); server-side error (500); network failure mid-request.
Common situations: User already deleted the embed in another tab and clicks delete again; non-admin user attempting to delete another user's embed; transient 5xx during deploy; embed was hard-deleted by a cleanup job between page load and click.
Related errors
- ${response.error || "Failed to create slash command"}
- ${res.reason}
- res.reason
- Could not update agent plugin status.
- Could not update agent plugin config.
AI-assisted analysis of Mintplex-Labs/anything-llm@526360e320 (2026-08-13).
Data as JSON: /api/errors/e412f2e4be35011d.
Report an issue: GitHub.