{"record":{"id":"8313551eac11acdf","repo":"Mintplex-Labs/anything-llm","slug":"failed-to-update-flow","errorCode":null,"errorMessage":"Failed to update flow","messagePattern":"Failed to update flow","errorType":"http","errorClass":null,"httpStatus":500,"severity":"error","filePath":"server/endpoints/agentFlows.js","lineNumber":187,"sourceCode":"    [validatedRequest, flexUserRoleValid([ROLES.admin])],\n    async (request, response) => {\n      try {\n        const { uuid } = request.params;\n        const { active } = request.body;\n\n        const flow = AgentFlows.loadFlow(uuid);\n        if (!flow) {\n          return response\n            .status(404)\n            .json({ success: false, error: \"Flow not found\" });\n        }\n\n        flow.config.active = active;\n        const { success } = AgentFlows.saveFlow(flow.name, flow.config, uuid);\n\n        if (!success) {\n          return response\n            .status(500)\n            .json({ success: false, error: \"Failed to update flow\" });\n        }\n\n        return response.json({ success: true, flow });\n      } catch (error) {\n        console.error(\"Error toggling flow:\", error);\n        response.status(500).json({ success: false, error: error.message });\n      }\n    }\n  );\n}\n\nmodule.exports = { agentFlowEndpoints };\n","sourceCodeStart":169,"sourceCodeEnd":201,"githubUrl":"https://github.com/Mintplex-Labs/anything-llm/blob/3aec848f2885144aa8f1e53b9731a04310d5d558/server/endpoints/agentFlows.js#L169-L201","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Check the server console 'Failed to save flow:' entry — it carries the underlying error.message (usually the unsupported-blocks text)","Open the flow in the builder and remove/replace unsupported blocks, then save before toggling","Verify storage/plugins/agent-flows is writable by the server process and the disk is not full"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"const SUPPORTED = new Set(['retrieval','web-scraping','web-search','sql-connector','ai-agent']); // match your build's FLOW_TYPES\nfunction flowUsesSupportedBlocks(config) {\n  return (config?.steps || []).every(s => SUPPORTED.has(s.type));\n}","typeGuard":null,"tryCatchPattern":"try {\n  const res = await fetch(`/api/agent-flows/${uuid}/toggle`, { method:'POST', headers:{'Content-Type':'application/json'}, body: JSON.stringify({ active }) });\n  const body = await res.json();\n  if (!res.ok || body.success === false) {\n    if (/unsupported blocks/i.test(body.error || '')) {\n      // open the builder, replace unsupported blocks, save, then re-toggle\n    }\n    throw new Error(body.error || `toggle failed: ${res.status}`);\n  }\n} catch (err) { console.error('toggle failed:', err.message); }","preventionTips":["Do not move flows between platforms (Desktop <-> Docker) without re-saving them in the target's builder","Validate step types against the deployed version's FLOW_TYPES before toggling imported flows","Keep the flows directory writable so the re-save in toggle cannot fail on fs errors"],"tags":["agent-flows","http-500","toggle","unsupported-blocks"],"backgroundTag":"config-validation-failed","analyzedSha":"3aec848f2885144aa8f1e53b9731a04310d5d558","analyzedAt":"2026-08-18T10:02:21.017Z","schemaVersion":2},"datasetVersion":"2026-08-21T13:17:26.733Z"}