Mintplex-Labs/anything-llm · error

Failed to update flow

Error message

Failed to update flow

What it means

POST /agent-flows/:uuid/toggle returns this 500 when re-saving the loaded flow fails. saveFlow returns {success:false,error} in two main cases: the flow contains step types not in FLOW_TYPES ('This flow includes unsupported blocks...'), typically after moving a flow between platforms (Desktop -> Docker) or versions; or fs.writeFileSync fails (permissions/disk). A config whose `steps` is missing also fails inside saveFlow's `config.steps.every` check.

Source

Thrown at server/endpoints/agentFlows.js:187

    [validatedRequest, flexUserRoleValid([ROLES.admin])],
    async (request, response) => {
      try {
        const { uuid } = request.params;
        const { active } = request.body;

        const flow = AgentFlows.loadFlow(uuid);
        if (!flow) {
          return response
            .status(404)
            .json({ success: false, error: "Flow not found" });
        }

        flow.config.active = active;
        const { success } = AgentFlows.saveFlow(flow.name, flow.config, uuid);

        if (!success) {
          return response
            .status(500)
            .json({ success: false, error: "Failed to update flow" });
        }

        return response.json({ success: true, flow });
      } catch (error) {
        console.error("Error toggling flow:", error);
        response.status(500).json({ success: false, error: error.message });
      }
    }
  );
}

module.exports = { agentFlowEndpoints };

View on GitHub (pinned to 3aec848f28)

Solutions

  1. Check the server console 'Failed to save flow:' entry — it carries the underlying error.message (usually the unsupported-blocks text)
  2. Open the flow in the builder and remove/replace unsupported blocks, then save before toggling
  3. Verify storage/plugins/agent-flows is writable by the server process and the disk is not full
Defensive patterns

Strategy: try-catch

Validate before calling

const SUPPORTED = new Set(['retrieval','web-scraping','web-search','sql-connector','ai-agent']); // match your build's FLOW_TYPES
function flowUsesSupportedBlocks(config) {
  return (config?.steps || []).every(s => SUPPORTED.has(s.type));
}

Try / catch

try {
  const res = await fetch(`/api/agent-flows/${uuid}/toggle`, { method:'POST', headers:{'Content-Type':'application/json'}, body: JSON.stringify({ active }) });
  const body = await res.json();
  if (!res.ok || body.success === false) {
    if (/unsupported blocks/i.test(body.error || '')) {
      // open the builder, replace unsupported blocks, save, then re-toggle
    }
    throw new Error(body.error || `toggle failed: ${res.status}`);
  }
} catch (err) { console.error('toggle failed:', err.message); }

Prevention

When it happens

Trigger: Toggling a flow created on a different platform/version whose block types the current build does not support; flows dir read-only or disk full at write time; a hand-edited flow JSON without a `steps` array.

Common situations: Importing Desktop-created flows (file-write/code-exec blocks) into a Docker deployment and toggling them; downgraded AnythingLLM versions lacking newer block types; container storage mounted read-only.

Understand the failure class

Background: Config validation failed: what "invalid value for {key}" and settings-rejection errors mean across 19 open-source libraries — this error's family across 19 libraries.

Related errors


AI-assisted analysis of Mintplex-Labs/anything-llm@3aec848f28 (2026-08-18). Data as JSON: /api/errors/8313551eac11acdf. Report an issue: GitHub.