{"record":{"id":"34d66dd3e037500f","repo":"Mintplex-Labs/anything-llm","slug":"res-error-failed-to-delete-flow","errorCode":null,"errorMessage":"${res.error || \"Failed to delete flow\"}","messagePattern":"\\$\\{res\\.error \\|\\| \"Failed to delete flow\"\\}","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"frontend/src/models/agentFlows.js","lineNumber":110,"sourceCode":"  //     .catch((e) => ({\n  //       success: false,\n  //       error: e.message,\n  //       results: null,\n  //     }));\n  // },\n\n  /**\n   * Delete a specific flow\n   * @param {string} uuid - The UUID of the flow to delete\n   * @returns {Promise<{success: boolean, error: string | null}>}\n   */\n  deleteFlow: async (uuid) => {\n    return await fetch(`${API_BASE}/agent-flows/${uuid}`, {\n      method: \"DELETE\",\n      headers: baseHeaders(),\n    })\n      .then((res) => {\n        if (!res.ok) throw new Error(res.error || \"Failed to delete flow\");\n        return res;\n      })\n      .then((res) => res.json())\n      .catch((e) => ({\n        success: false,\n        error: e.message,\n      }));\n  },\n\n  /**\n   * Toggle a flow's active status\n   * @param {string} uuid - The UUID of the flow to toggle\n   * @param {boolean} active - The new active status\n   * @returns {Promise<{success: boolean, error: string | null}>}\n   */\n  toggleFlow: async (uuid, active) => {\n    try {\n      const result = await fetch(`${API_BASE}/agent-flows/${uuid}/toggle`, {","sourceCodeStart":92,"sourceCodeEnd":128,"githubUrl":"https://github.com/Mintplex-Labs/anything-llm/blob/526360e320da9d1b36074be5ed64fe76e5bbfbbd/frontend/src/models/agentFlows.js#L92-L128","documentation":"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.","triggerScenarios":"Deleting an already-deleted uuid (404), deleting a flow owned by another workspace (403), 401 expired session, backend 500 during deletion.","commonSituations":"Double-click delete (second call 404s); stale list after another user removed the flow; permissions mismatch.","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."],"exampleFix":"// before\n.then((res) => {\n  if (!res.ok) throw new Error(res.error || 'Failed to delete flow');\n  return res;\n})\n\n// after\n.then(async (res) => {\n  const response = await res.json();\n  if (!res.ok) throw new Error(response?.error || `Failed to delete flow (HTTP ${res.status})`);\n  return response;\n})","handlingStrategy":"try-catch","validationCode":"function assertUuid(uuid) {\n  if (!/^[0-9a-fA-F-]{36}$/.test(String(uuid || ''))) {\n    throw new Error('A valid flow UUID is required');\n  }\n}","typeGuard":"function isUuid(v) { return /^[0-9a-fA-F-]{36}$/.test(String(v || '')); }","tryCatchPattern":"const { success, error } = await AgentFlows.deleteFlow(uuid);\nif (!success) {\n  if (/404|not found/i.test(error)) { /* treat as already-deleted -> success */ return; }\n  showToast(error);\n}","preventionTips":["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."],"tags":["frontend","agent-flows","fetch","bug","network"],"backgroundTag":null,"analyzedSha":"526360e320da9d1b36074be5ed64fe76e5bbfbbd","analyzedAt":"2026-08-13T01:45:47.170Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}