langflow-ai/langflow · error · Error
Invalid flow data
Error message
Invalid flow data
What it means
Thrown by the useUploadFlow hook when a parsed upload file yields a flow object that has no `data` property. Langflow expects every uploaded JSON entry to be a flow object whose graph lives under `data` (nodes/edges); an entry without it is treated as structurally invalid and the whole upload is aborted before any flow is saved or pasted.
Source
Thrown at src/frontend/src/hooks/flows/use-upload-flow.ts:88
) {
throw new Error(
"You cannot upload a component as a flow or vice versa",
);
} else {
let currentPosition = position;
for (const flow of flows) {
if (flow.data) {
if (currentPosition) {
paste(flow.data, currentPosition);
currentPosition = {
x: currentPosition.x + 50,
y: currentPosition.y + 50,
};
} else {
await addFlow({ flow });
}
} else {
throw new Error("Invalid flow data");
}
}
}
} catch (e) {
throw e;
}
};
return uploadFlow;
};
export default useUploadFlow;
View on GitHub (pinned to 976ec789d2)
Solutions
- Open the uploaded JSON and confirm each top-level object contains a `data` object with `nodes` and `edges`
- Re-export the flow from Langflow's UI (Flow Settings > Export) rather than copying a flow-list API response
- If importing multiple flows, ensure the file is an array where EVERY element has `data` — one bad entry aborts the loop
- Validate the file shape client-side before calling uploadFlow (see type guard below)
Example fix
// before
await uploadFlow({ files }); // throws mid-loop on first entry without data
// after
const flows = JSON.parse(await files[0].text());
const ok = (Array.isArray(flows) ? flows : [flows]).every(
(f) => f && typeof f === "object" && f.data && Array.isArray(f.data.nodes),
);
if (!ok) throw new Error("File is not a valid Langflow flow export");
await uploadFlow({ files }); Defensive patterns
Strategy: type-guard
Validate before calling
const isFlowExport = (v: unknown): v is { data: { nodes: unknown[]; edges: unknown[] } } =>
typeof v === "object" && v !== null &&
"data" in v && typeof (v as any).data === "object" &&
Array.isArray((v as any).data?.nodes);
const parsed = JSON.parse(text);
const flows = Array.isArray(parsed) ? parsed : [parsed];
if (!flows.every(isFlowExport)) {
alert("File is not a valid Langflow flow export (missing data.nodes)");
} Type guard
function isFlowExport(v: unknown): v is { data: { nodes: unknown[]; edges: unknown[] } } {
return (
typeof v === "object" && v !== null &&
"data" in v && typeof (v as Record<string, unknown>).data === "object"
);
} Try / catch
try {
await uploadFlow({ files });
} catch (e) {
if (e instanceof Error && e.message === "Invalid flow data") {
// show a file-format message; do not retry the same file
} else throw e;
} Prevention
- Only upload files exported from Langflow's export action or produced by its API
- Validate the parsed JSON shape (data.nodes/data.edges present) before calling uploadFlow
- When generating flow JSON programmatically, always include the `data` envelope
When it happens
Trigger: Uploading a JSON file via the flow-import UI (or drag-drop onto the canvas with a paste position) where getFlowsFromFiles returns objects lacking a `data` key — e.g. a hand-written JSON, an API response wrapper like {id, name} without the graph, or a partially exported/corrupted flow file.
Common situations: Users exporting from a different Langflow version or another tool, editing exported JSON and accidentally deleting the `data` field, or uploading a file that contains flow metadata (list endpoint output) instead of the full flow export.
Related errors
- Invalid JSON format.
- No valid MCP server found in the input.
- Deployment name is required
- error: invalid JSON in {source}: {exc}
- error: {source} entries field must be a list
AI-assisted analysis of langflow-ai/langflow@976ec789d2 (2026-08-14).
Data as JSON: /api/errors/2b3f574f2e044f88.
Report an issue: GitHub.