Mintplex-Labs/anything-llm · warning · Error

Flow not found

Error message

Flow ${uuid} not found

What it means

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.

Solutions

  1. Re-list flows (AgentFlows.listFlows() or refresh the UI) and use the current uuid.
  2. Treat { success: false, error: 'Flow ... not found' } as idempotent success if your goal is simply 'make it gone'.
  3. Verify STORAGE_DIR points at the same volume the flows were written to.
  4. Ensure you pass the UUID (uuidv4 filename stem), not the flow's human-readable name.
Defensive patterns

Strategy: validation

Validate before calling

const AgentFlows = require("../utils/agentFlows");

function flowExists(uuid) {
  return AgentFlows.listFlows().some((f) => f.uuid === uuid);
}

if (!flowExists(uuid)) return { success: true, note: "already gone" }; // idempotent delete

Try / catch

const res = AgentFlows.deleteFlow(uuid);
if (!res.success && /not found/.test(res.error)) {
  // treat as idempotent success or refresh the UI list
  return { success: true, idempotent: true };
}

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Understand the failure class

Background: 'Could not be found', 'does not exist', 'not found in database': the resource-not-found family when an ID, slug, key, or URI lookup comes back empty — this error's family across 20 libraries.

Related errors


AI-assisted analysis of Mintplex-Labs/anything-llm@f92433b4ea (2026-08-18). Data as JSON: /api/errors/0d1654f6c57af5b9. Report an issue: GitHub.

Appendix: source

Thrown at server/utils/agentFlows/index.js:161

      }));
    } catch (error) {
      console.error("Failed to list flows:", error);
      return [];
    }
  }

  /**
   * Delete a flow by UUID
   * @param {string} uuid - The UUID of the flow to delete
   * @returns {Object} Result of the delete operation
   */
  static deleteFlow(uuid) {
    try {
      const filePath = normalizePath(
        path.join(AgentFlows.flowsDir, `${uuid}.json`)
      );
      if (!fs.existsSync(filePath) || !isWithin(AgentFlows.flowsDir, filePath))
        throw new Error(`Flow ${uuid} not found`);
      fs.rmSync(filePath);
      return { success: true };
    } catch (error) {
      console.error("Failed to delete flow:", error);
      return { success: false, error: error.message };
    }
  }

  /**
   * Execute a flow by UUID
   * @param {string} uuid - The UUID of the flow to execute
   * @param {Object} variables - Initial variables for the flow
   * @param {Object} aibitat - The aibitat instance from the agent handler
   * @returns {Promise<Object>} Result of flow execution
   */
  static async executeFlow(uuid, variables = {}, aibitat = null) {
    const flow = AgentFlows.loadFlow(uuid);
    if (!flow) throw new Error(`Flow ${uuid} not found`);

View on GitHub (pinned to f92433b4ea)