{"record":{"id":"2b3f574f2e044f88","repo":"langflow-ai/langflow","slug":"invalid-flow-data","errorCode":null,"errorMessage":"Invalid flow data","messagePattern":"Invalid flow data","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"src/frontend/src/hooks/flows/use-upload-flow.ts","lineNumber":88,"sourceCode":"      ) {\n        throw new Error(\n          \"You cannot upload a component as a flow or vice versa\",\n        );\n      } else {\n        let currentPosition = position;\n        for (const flow of flows) {\n          if (flow.data) {\n            if (currentPosition) {\n              paste(flow.data, currentPosition);\n              currentPosition = {\n                x: currentPosition.x + 50,\n                y: currentPosition.y + 50,\n              };\n            } else {\n              await addFlow({ flow });\n            }\n          } else {\n            throw new Error(\"Invalid flow data\");\n          }\n        }\n      }\n    } catch (e) {\n      throw e;\n    }\n  };\n\n  return uploadFlow;\n};\n\nexport default useUploadFlow;\n","sourceCodeStart":70,"sourceCodeEnd":101,"githubUrl":"https://github.com/langflow-ai/langflow/blob/976ec789d2886a86de109c044d089d68e96c9a35/src/frontend/src/hooks/flows/use-upload-flow.ts#L70-L101","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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)"],"exampleFix":"// before\nawait uploadFlow({ files }); // throws mid-loop on first entry without data\n\n// after\nconst flows = JSON.parse(await files[0].text());\nconst ok = (Array.isArray(flows) ? flows : [flows]).every(\n  (f) => f && typeof f === \"object\" && f.data && Array.isArray(f.data.nodes),\n);\nif (!ok) throw new Error(\"File is not a valid Langflow flow export\");\nawait uploadFlow({ files });","handlingStrategy":"type-guard","validationCode":"const isFlowExport = (v: unknown): v is { data: { nodes: unknown[]; edges: unknown[] } } =>\n  typeof v === \"object\" && v !== null &&\n  \"data\" in v && typeof (v as any).data === \"object\" &&\n  Array.isArray((v as any).data?.nodes);\n\nconst parsed = JSON.parse(text);\nconst flows = Array.isArray(parsed) ? parsed : [parsed];\nif (!flows.every(isFlowExport)) {\n  alert(\"File is not a valid Langflow flow export (missing data.nodes)\");\n}","typeGuard":"function isFlowExport(v: unknown): v is { data: { nodes: unknown[]; edges: unknown[] } } {\n  return (\n    typeof v === \"object\" && v !== null &&\n    \"data\" in v && typeof (v as Record<string, unknown>).data === \"object\"\n  );\n}","tryCatchPattern":"try {\n  await uploadFlow({ files });\n} catch (e) {\n  if (e instanceof Error && e.message === \"Invalid flow data\") {\n    // show a file-format message; do not retry the same file\n  } else throw e;\n}","preventionTips":["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"],"tags":["frontend","flow-import","validation","json"],"backgroundTag":null,"analyzedSha":"976ec789d2886a86de109c044d089d68e96c9a35","analyzedAt":"2026-08-14T18:23:12.227Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}