{"record":{"id":"9ed29e9f8c0aa6ef","repo":"Mintplex-Labs/anything-llm","slug":"error-message-9ed29e","errorCode":null,"errorMessage":"error.message","messagePattern":"error\\.message","errorType":"http","errorClass":null,"httpStatus":500,"severity":"error","filePath":"server/endpoints/agentFlows.js","lineNumber":45,"sourceCode":"        const flow = AgentFlows.saveFlow(name, config, uuid);\n        if (!flow || !flow.success)\n          return response\n            .status(200)\n            .json({ flow: null, error: flow.error || \"Failed to save flow\" });\n\n        if (!uuid) {\n          await Telemetry.sendTelemetry(\"agent_flow_created\", {\n            blockCount: config.blocks?.length || 0,\n          });\n        }\n\n        return response.status(200).json({\n          success: true,\n          flow,\n        });\n      } catch (error) {\n        console.error(\"Error saving flow:\", error);\n        return response.status(500).json({\n          success: false,\n          error: error.message,\n        });\n      }\n    }\n  );\n\n  // List all available flows\n  app.get(\n    \"/agent-flows/list\",\n    [validatedRequest, flexUserRoleValid([ROLES.admin])],\n    async (_request, response) => {\n      try {\n        const flows = AgentFlows.listFlows();\n        return response.status(200).json({\n          success: true,\n          flows,\n        });","sourceCodeStart":27,"sourceCodeEnd":63,"githubUrl":"https://github.com/Mintplex-Labs/anything-llm/blob/3aec848f2885144aa8f1e53b9731a04310d5d558/server/endpoints/agentFlows.js#L27-L63","documentation":"This is the 500 catch-all of POST /agent-flows/save. It echoes `error.message` from any exception thrown inside the handler. Because AgentFlows.saveFlow wraps its own work in try/catch and returns {success:false} instead of throwing, this 500 in practice fires when the awaited Telemetry.sendTelemetry call throws or response serialization fails — not from the flow file write itself (that failure comes back as a 200 with {flow:null, error}).","triggerScenarios":"Telemetry.sendTiming/sendTelemetry throwing (e.g. a patched or broken telemetry module), or an exception raised while JSON-serializing the response. A save rejected for unsupported block types does NOT hit this path — it returns 200 with error 'This flow includes unsupported blocks...'.","commonSituations":"Broken telemetry dependency in custom builds; monkey-patched server internals; disk-full conditions that make an auxiliary call throw before the response is sent.","solutions":["Read the console output — the handler logs 'Error saving flow:' with the full stack right before responding","If the message mentions telemetry, check the Telemetry module/dependency; you can also inspect the 200-with-error response shape for saveFlow business failures instead","Verify STORAGE_DIR is writable and exists so saveFlow path resolution succeeds"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try {\n  const res = await fetch('/api/agent-flows/save', { method:'POST', headers:{'Content-Type':'application/json' }, body });\n  const data = await res.json();\n  if (!res.ok || data.success === false) {\n    throw new Error(data.error || `save failed with ${res.status}`);\n  }\n  return data.flow;\n} catch (err) {\n  // 500 path: surface server console detail; retrying rarely helps without a fix\n  console.error('agent-flow save failed:', err.message);\n  throw err;\n}","preventionTips":["Distinguish the 200-with-error shape ({flow:null,error}) from a true 500 when handling save results","Watch server logs for 'Error saving flow:' — the client only gets error.message","Keep STORAGE_DIR writable so the underlying save path never degrades"],"tags":["agent-flows","http-500","catch-all","error-passthrough"],"backgroundTag":"http-500-internal-server-error","analyzedSha":"3aec848f2885144aa8f1e53b9731a04310d5d558","analyzedAt":"2026-08-18T10:02:21.017Z","schemaVersion":2},"datasetVersion":"2026-08-21T13:17:26.733Z"}