Mintplex-Labs/anything-llm · error
error.message
Error message
error.message
What it means
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}).
Source
Thrown at server/endpoints/agentFlows.js:45
const flow = AgentFlows.saveFlow(name, config, uuid);
if (!flow || !flow.success)
return response
.status(200)
.json({ flow: null, error: flow.error || "Failed to save flow" });
if (!uuid) {
await Telemetry.sendTelemetry("agent_flow_created", {
blockCount: config.blocks?.length || 0,
});
}
return response.status(200).json({
success: true,
flow,
});
} catch (error) {
console.error("Error saving flow:", error);
return response.status(500).json({
success: false,
error: error.message,
});
}
}
);
// List all available flows
app.get(
"/agent-flows/list",
[validatedRequest, flexUserRoleValid([ROLES.admin])],
async (_request, response) => {
try {
const flows = AgentFlows.listFlows();
return response.status(200).json({
success: true,
flows,
});View on GitHub (pinned to 3aec848f28)
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
Defensive patterns
Strategy: try-catch
Try / catch
try {
const res = await fetch('/api/agent-flows/save', { method:'POST', headers:{'Content-Type':'application/json' }, body });
const data = await res.json();
if (!res.ok || data.success === false) {
throw new Error(data.error || `save failed with ${res.status}`);
}
return data.flow;
} catch (err) {
// 500 path: surface server console detail; retrying rarely helps without a fix
console.error('agent-flow save failed:', err.message);
throw err;
} Prevention
- 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
When it happens
Trigger: 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...'.
Common situations: Broken telemetry dependency in custom builds; monkey-patched server internals; disk-full conditions that make an auxiliary call throw before the response is sent.
Related errors
AI-assisted analysis of Mintplex-Labs/anything-llm@3aec848f28 (2026-08-18).
Data as JSON: /api/errors/9ed29e9f8c0aa6ef.
Report an issue: GitHub.