Mintplex-Labs/anything-llm · error · Error
Failed to import agent flow. ${e.message}
Error message
Failed to import agent flow. ${e.message} What it means
The community-hub import step parses item.flow with safeJsonParse and calls AgentFlows.saveFlow(item.name, flowInfo), then optionally AgentFlows.toggleFlow(flow.uuid, true). Any failure — malformed flow JSON, steps the local schema rejects, auth — is caught and shown as 'Failed to import agent flow'.
Source
Thrown at frontend/src/pages/GeneralSettings/CommunityHub/ImportItem/Steps/PullAndReview/HubItem/AgentFlow.jsx:21
import showToast from "@/utils/toast";
import paths from "@/utils/paths";
import { CircleNotch } from "@phosphor-icons/react";
import { useState } from "react";
import AgentFlows from "@/models/agentFlows";
import { safeJsonParse } from "@/utils/request";
export default function AgentFlow({ item, setStep }) {
const flowInfo = safeJsonParse(item.flow, { steps: [] });
const [loading, setLoading] = useState(false);
async function importAgentFlow() {
try {
setLoading(true);
const { success, error, flow } = await AgentFlows.saveFlow(
item.name,
flowInfo
);
if (!success) throw new Error(error);
if (!!flow?.uuid) await AgentFlows.toggleFlow(flow.uuid, true); // Enable the flow automatically after import
showToast(`Agent flow imported successfully!`, "success");
setStep(CommunityHubImportItemSteps.completed.key);
} catch (e) {
console.error(e);
showToast(`Failed to import agent flow. ${e.message}`, "error");
} finally {
setLoading(false);
}
}
return (
<div className="flex flex-col mt-4 gap-y-4">
<div className="flex flex-col gap-y-1">
<h2 className="text-base text-theme-text-primary font-semibold">
Import Agent Flow "{item.name}"
</h2>View on GitHub (pinned to 3aec848f28)
Solutions
- Verify item.flow parses and its step types exist in your installed version before importing.
- Confirm the admin session is still valid and retry.
- Check the Network tab for the saveFlow response to see whether save or toggle failed.
- If save succeeded but toggle failed, enable the imported flow manually from the agent flows admin page.
Example fix
// before
const flowInfo = safeJsonParse(item.flow, { steps: [] });
const { success, error, flow } = await AgentFlows.saveFlow(item.name, flowInfo);
// after
const flowInfo = safeJsonParse(item.flow, { steps: [] });
if (!flowInfo?.steps?.length) {
showToast('This hub item has no importable flow steps.', 'error');
return;
}
const { success, error, flow } = await AgentFlows.saveFlow(item.name, flowInfo); Defensive patterns
Strategy: validation
Validate before calling
function isImportableFlow(flowInfo) {
return (
flowInfo != null &&
Array.isArray(flowInfo.steps) &&
flowInfo.steps.length > 0 &&
flowInfo.steps.every((s) => s && typeof s.type === 'string')
);
}
// before saveFlow:
if (!isImportableFlow(safeJsonParse(item.flow, { steps: [] }))) {
showToast('Hub item contains no importable flow steps.', 'error');
return;
} Try / catch
try {
const { success, error, flow } = await AgentFlows.saveFlow(item.name, flowInfo);
if (!success) throw new Error(error);
if (!!flow?.uuid) await AgentFlows.toggleFlow(flow.uuid, true);
} catch (e) {
console.error(e);
showToast(`Failed to import agent flow. ${e.message}`, 'error');
} finally {
setLoading(false);
} Prevention
- Validate the parsed flow shape before importing — hub items come from other instances and versions.
- Confirm the admin session is alive before starting an import.
- If only the post-import toggle fails, instruct the user to enable the flow manually instead of restarting the import.
When it happens
Trigger: Importing a hub item whose flow JSON is malformed or contains step/block types unknown to your build; importing without a valid admin session; a name collision the backend refuses; the post-save toggleFlow call failing after a successful save.
Common situations: Importing a flow authored on a newer version with different block types; hub item payload truncated in transit; session expired between browsing the hub and clicking import.
Related errors
- Failed to publish agent flow: ${error.message}
- Failed to save agent flow. ${error.message}
- Failed to toggle flow
- Community Hub connection key not found
- Unknown error
AI-assisted analysis of Mintplex-Labs/anything-llm@3aec848f28 (2026-08-18).
Data as JSON: /api/errors/602a735b5efe9373.
Report an issue: GitHub.