{"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/526360e320da9d1b36074be5ed64fe76e5bbfbbd/server/utils/agentFlows/index.js#L143-L179","documentation":"Thrown by AgentFlows.deleteFlow() when no file exists at STORAGE_DIR/plugins/agent-flows/{uuid}.json, or the resolved path is not within the flows directory. It is caught inside deleteFlow and returned as { success:false, error } so the caller sees a structured failure, not an exception.","triggerScenarios":"Calling deleteFlow() with a uuid whose .json file was already removed, never existed, or lives outside the flows directory due to a path-traversal guard (isWithin) failing. STORAGE_DIR having changed between calls also produces this.","commonSituations":"Double-deleting a flow; passing a stale uuid from a cached UI list; STORAGE_DIR environment variable changed so the flows directory moved; the flow file was deleted manually on disk.","solutions":["Call AgentFlows.listFlows() to confirm the uuid still exists before deleting.","Verify STORAGE_DIR is consistent with where the flow was created.","Treat a not-found delete as a no-op success if idempotency is desired in the caller."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"function flowExists(uuid) {\n  return AgentFlows.loadFlow(uuid) !== null;\n}\n// guard before delete\nif (!flowExists(uuid)) return { success: true }; // idempotent no-op","typeGuard":null,"tryCatchPattern":"const res = AgentFlows.deleteFlow(uuid);\nif (!res.success && res.error.endsWith(\"not found\")) {\n  // treat as already-deleted / idempotent success\n}","preventionTips":["Call listFlows() to confirm a uuid exists before deleting.","Treat deleteFlow on a missing uuid as an idempotent success in callers.","Keep STORAGE_DIR stable so the flows directory does not move between operations."],"tags":["agent-flows","file-not-found","delete"],"backgroundTag":null,"analyzedSha":"526360e320da9d1b36074be5ed64fe76e5bbfbbd","analyzedAt":"2026-08-13T01:45:47.170Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}