{"record":{"id":"0d1654f6c57af5b9","repo":"Mintplex-Labs/anything-llm","slug":"flow-uuid-not-found","errorCode":null,"errorMessage":"Flow ${uuid} not found","messagePattern":"Flow (.+?) not found","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"warning","filePath":"server/utils/agentFlows/index.js","lineNumber":161,"sourceCode":"      }));\n    } catch (error) {\n      console.error(\"Failed to list flows:\", error);\n      return [];\n    }\n  }\n\n  /**\n   * Delete a flow by UUID\n   * @param {string} uuid - The UUID of the flow to delete\n   * @returns {Object} Result of the delete operation\n   */\n  static deleteFlow(uuid) {\n    try {\n      const filePath = normalizePath(\n        path.join(AgentFlows.flowsDir, `${uuid}.json`)\n      );\n      if (!fs.existsSync(filePath) || !isWithin(AgentFlows.flowsDir, filePath))\n        throw new Error(`Flow ${uuid} not found`);\n      fs.rmSync(filePath);\n      return { success: true };\n    } catch (error) {\n      console.error(\"Failed to delete flow:\", error);\n      return { success: false, error: error.message };\n    }\n  }\n\n  /**\n   * Execute a flow by UUID\n   * @param {string} uuid - The UUID of the flow to execute\n   * @param {Object} variables - Initial variables for the flow\n   * @param {Object} aibitat - The aibitat instance from the agent handler\n   * @returns {Promise<Object>} Result of flow execution\n   */\n  static async executeFlow(uuid, variables = {}, aibitat = null) {\n    const flow = AgentFlows.loadFlow(uuid);\n    if (!flow) throw new Error(`Flow ${uuid} not found`);","sourceCodeStart":143,"sourceCodeEnd":179,"githubUrl":"https://github.com/Mintplex-Labs/anything-llm/blob/f92433b4ea0598492a1e6645ea22addbb4dd1287/server/utils/agentFlows/index.js#L143-L179","documentation":"Thrown by AgentFlows.deleteFlow when no `<uuid>.json` exists under the flows directory (storage/plugins/agent-flows, or STORAGE_DIR/plugins/agent-flows), or when the normalized path falls outside that directory (isWithin guard). It is caught in-place and returned as { success: false, error: 'Flow <uuid> not found' } — the caller gets a result object, not an exception.","triggerScenarios":"Calling deleteFlow with a UUID that was already deleted; a stale UUID from a cached UI list; passing a name instead of the UUID; storage directory wiped or remounted between listing and deleting; a path-traversal-style uuid rejected by isWithin.","commonSituations":"Two clients with the flows page open — one deletes, the other's delete 404s; flow files removed by volume change or backup restore; UI list desynced after import; copy-pasting the flow's display name rather than its uuid.","solutions":["Re-list flows (AgentFlows.listFlows() or refresh the UI) and use the current uuid.","Treat { success: false, error: 'Flow ... not found' } as idempotent success if your goal is simply 'make it gone'.","Verify STORAGE_DIR points at the same volume the flows were written to.","Ensure you pass the UUID (uuidv4 filename stem), not the flow's human-readable name."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"const AgentFlows = require(\"../utils/agentFlows\");\n\nfunction flowExists(uuid) {\n  return AgentFlows.listFlows().some((f) => f.uuid === uuid);\n}\n\nif (!flowExists(uuid)) return { success: true, note: \"already gone\" }; // idempotent delete","typeGuard":null,"tryCatchPattern":"const res = AgentFlows.deleteFlow(uuid);\nif (!res.success && /not found/.test(res.error)) {\n  // treat as idempotent success or refresh the UI list\n  return { success: true, idempotent: true };\n}","preventionTips":["Make deletion flows idempotent: a 'not found' result is usually the desired end state.","Pass the UUID (filename stem), never the display name.","Refresh the flow list after any delete/import so concurrent UIs stay in sync."],"tags":["agent-flows","resource-not-found","crud","storage"],"backgroundTag":"resource-not-found","analyzedSha":"f92433b4ea0598492a1e6645ea22addbb4dd1287","analyzedAt":"2026-08-18T10:02:21.017Z","contentChangedAt":"2026-08-18T10:02:21.017Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}