Mintplex-Labs/anything-llm · error
${res.error || "Failed to delete flow"}
Error message
${res.error || "Failed to delete flow"} What it means
Thrown from `deleteFlow` on a non-ok `DELETE /api/agent-flows/:uuid`. Same `res.error`-always-undefined defect as 51/52: the user always sees 'Failed to delete flow', never the server's reason.
Source
Thrown at frontend/src/models/agentFlows.js:110
// .catch((e) => ({
// success: false,
// error: e.message,
// results: null,
// }));
// },
/**
* Delete a specific flow
* @param {string} uuid - The UUID of the flow to delete
* @returns {Promise<{success: boolean, error: string | null}>}
*/
deleteFlow: async (uuid) => {
return await fetch(`${API_BASE}/agent-flows/${uuid}`, {
method: "DELETE",
headers: baseHeaders(),
})
.then((res) => {
if (!res.ok) throw new Error(res.error || "Failed to delete flow");
return res;
})
.then((res) => res.json())
.catch((e) => ({
success: false,
error: e.message,
}));
},
/**
* Toggle a flow's active status
* @param {string} uuid - The UUID of the flow to toggle
* @param {boolean} active - The new active status
* @returns {Promise<{success: boolean, error: string | null}>}
*/
toggleFlow: async (uuid, active) => {
try {
const result = await fetch(`${API_BASE}/agent-flows/${uuid}/toggle`, {View on GitHub (pinned to 526360e320)
Solutions
- Patch the throw to consume the JSON body's `error` field.
- Treat 404 as success (already gone) for idempotent delete UX.
- Re-authenticate on 401; refresh the flow list after a 404.
- Check network tab for the real status/body during debugging.
Example fix
// before
.then((res) => {
if (!res.ok) throw new Error(res.error || 'Failed to delete flow');
return res;
})
// after
.then(async (res) => {
const response = await res.json();
if (!res.ok) throw new Error(response?.error || `Failed to delete flow (HTTP ${res.status})`);
return response;
}) Defensive patterns
Strategy: try-catch
Validate before calling
function assertUuid(uuid) {
if (!/^[0-9a-fA-F-]{36}$/.test(String(uuid || ''))) {
throw new Error('A valid flow UUID is required');
}
} Type guard
function isUuid(v) { return /^[0-9a-fA-F-]{36}$/.test(String(v || '')); } Try / catch
const { success, error } = await AgentFlows.deleteFlow(uuid);
if (!success) {
if (/404|not found/i.test(error)) { /* treat as already-deleted -> success */ return; }
showToast(error);
} Prevention
- Patch the model to read `response.error` from the JSON body.
- Treat 404 as idempotent success for delete UX.
- Disable the delete button until the request resolves to avoid double-clicks.
When it happens
Trigger: Deleting an already-deleted uuid (404), deleting a flow owned by another workspace (403), 401 expired session, backend 500 during deletion.
Common situations: Double-click delete (second call 404s); stale list after another user removed the flow; permissions mismatch.
Related errors
- ${res.error || "Failed to save flow"}
- ${res.error || "Failed to get flow"}
- ${res.error || "Failed to toggle flow"}
- ${res.statusText || "Error fetching api keys."}
- ${res.statusText || "Error generating api key."}
AI-assisted analysis of Mintplex-Labs/anything-llm@526360e320 (2026-08-13).
Data as JSON: /api/errors/34d66dd3e037500f.
Report an issue: GitHub.