{"record":{"id":"6d97bf95b9468e47","repo":"langflow-ai/langflow","slug":"flow-data-could-not-be-copied-the-data-may-be-cor","errorCode":null,"errorMessage":"Flow data could not be copied. The data may be corrupted.","messagePattern":"Flow data could not be copied\\. The data may be corrupted\\.","errorType":"http","errorClass":"HTTPException","httpStatus":422,"severity":"error","filePath":"src/backend/base/langflow/api/v1/flow_version.py","lineNumber":271,"sourceCode":"    )\n\n    # Verify version entry belongs to this flow\n    try:\n        target_entry = await get_flow_version_entry_or_raise(session, version_id, current_user.id, flow_id=flow_id)\n    except FlowVersionNotFoundError as exc:\n        raise HTTPException(status_code=404, detail=\"Version entry not found\") from exc\n\n    # Guard against activating a version with no data (check before auto-snapshot)\n    if target_entry.data is None:\n        raise HTTPException(status_code=400, detail=\"Cannot activate a version with no data\")\n\n    # Capture copies of both data dicts before the savepoint to avoid stale\n    # reads if pruning inside create_flow_version_entry deletes old entries.\n    try:\n        current_data = copy.deepcopy(flow.data) if save_draft else None\n        target_data = copy.deepcopy(target_entry.data)\n    except Exception as exc:\n        raise HTTPException(\n            status_code=422,\n            detail=\"Flow data could not be copied. The data may be corrupted.\",\n        ) from exc\n\n    # Wrap auto-snapshot + flow overwrite in a single savepoint for atomicity.\n    # If the flow update fails, the auto-snapshot is also rolled back.\n    try:\n        async with session.begin_nested():\n            if save_draft and current_data is not None:\n                await create_flow_version_entry(\n                    session,\n                    flow_id=flow.id,\n                    user_id=current_user.id,\n                    data=current_data,\n                    description=f\"Auto-saved before activating v{target_entry.version_number}\",\n                )\n\n            flow.data = target_data","sourceCodeStart":253,"sourceCodeEnd":289,"githubUrl":"https://github.com/langflow-ai/langflow/blob/976ec789d2886a86de109c044d089d68e96c9a35/src/backend/base/langflow/api/v1/flow_version.py#L253-L289","documentation":"422 from the version-activation endpoint: copy.deepcopy of flow.data (for the pre-activation auto-snapshot) or of target_entry.data failed. Same failure class as the snapshot-endpoint 422 — the persisted JSON contains something deepcopy cannot duplicate — but here it can be either the live flow data or the stored version data that is bad.","triggerScenarios":"Activating a version when either the current flow.data or the target version's data is corrupt/hand-modified (recursive structures, invalid types) so deepcopy raises.","commonSituations":"Externally imported or SQL-edited flow/version rows; restored databases with serialization artifacts.","solutions":["Determine which side is bad: snapshot the flow alone (POST /versions/) — if that 422s, flow.data is corrupt; if it succeeds, the target version's data is corrupt","Re-save the flow from the UI to normalise flow.data, then retry activation","For a corrupt version entry, delete it and rely on another version, or repair its data column from an export"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"await axios.post(`/api/v1/flows/${flowId}/versions/`); // if this succeeds, flow.data is fine; failure localises corruption","typeGuard":null,"tryCatchPattern":"catch (e) {\n  if (e.response?.status === 422 && /could not be copied/.test(e.response.data?.detail))\n    notifyDataCorruption('flow or version data');\n  throw e;\n}","preventionTips":["Snapshot before activating — it doubles as a corruption probe for flow.data","Never hand-edit flow or version data in the database","Keep exports of important flows so corrupted rows can be rebuilt"],"tags":["http-422","flow-versions","activate","deepcopy","data-corruption"],"backgroundTag":null,"analyzedSha":"976ec789d2886a86de109c044d089d68e96c9a35","analyzedAt":"2026-08-14T18:23:12.227Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}