{"record":{"id":"fb54952bdbaa37cf","repo":"langflow-ai/langflow","slug":"flow-data-could-not-be-copied-for-snapshot-the-da","errorCode":null,"errorMessage":"Flow data could not be copied for snapshot. The data may be corrupted.","messagePattern":"Flow data could not be copied for snapshot\\. The data may be corrupted\\.","errorType":"http","errorClass":"HTTPException","httpStatus":422,"severity":"error","filePath":"src/backend/base/langflow/api/v1/flow_version.py","lineNumber":218,"sourceCode":"    current_user: CurrentActiveUser,\n    session: DbSession,\n    body: FlowVersionCreate | None = None,\n) -> FlowVersionRead:\n    flow = await _get_user_flow(session, flow_id, current_user.id)\n    await ensure_flow_permission(\n        current_user,\n        FlowAction.WRITE,\n        flow_id=flow.id,\n        flow_user_id=flow.user_id,\n        workspace_id=flow.workspace_id,\n        folder_id=flow.folder_id,\n    )\n    description = body.description if body else None\n\n    try:\n        data = copy.deepcopy(flow.data)\n    except Exception as exc:\n        raise HTTPException(\n            status_code=422,\n            detail=\"Flow data could not be copied for snapshot. The data may be corrupted.\",\n        ) from exc\n\n    try:\n        entry = await create_flow_version_entry(\n            session,\n            flow_id=flow.id,\n            user_id=current_user.id,\n            data=data,\n            description=description,\n        )\n    except FlowVersionError as exc:\n        raise _translate_version_error(exc) from exc\n    return _version_to_read(entry)\n\n\n@router.post(\"/{version_id}/activate\")","sourceCodeStart":200,"sourceCodeEnd":236,"githubUrl":"https://github.com/langflow-ai/langflow/blob/976ec789d2886a86de109c044d089d68e96c9a35/src/backend/base/langflow/api/v1/flow_version.py#L200-L236","documentation":"422 from POST /flows/{flow_id}/versions/ (create_snapshot): after the WRITE-permission check on the flow, copy.deepcopy(flow.data) raised. flow.data is stored as JSON; if the persisted structure contains objects deepcopy cannot duplicate (non-picklable or recursive structures injected via a custom DB write), the snapshot aborts before any version row is created.","triggerScenarios":"Creating a snapshot when flow.data was corrupted or hand-modified in the database — e.g. directly-uploaded flow rows containing deeply recursive dicts or exotic types — so deepcopy fails.","commonSituations":"Flows imported from external tooling that wrote non-standard JSON structures into flow.data; databases restored from partially-serialized dumps; extremely unusual data inserted via raw SQL.","solutions":["GET the flow and inspect flow.data for anomalies (self-references, absurd nesting) — fix or re-save the flow from the UI so data is normalised","If the flow opens in the UI, make any small edit and save to rewrite data cleanly, then snapshot","As a last resort recreate the flow from its exported JSON"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"const flow = (await axios.get(`/api/v1/flows/${flowId}`)).data;\nconst snapshotSafe = flow.data == null || typeof flow.data === 'object'; // shallow sanity only","typeGuard":"const isPlainFlowData = (d: unknown): d is Record<string, unknown> =>\n  d === null || (typeof d === 'object' && !Array.isArray(d));","tryCatchPattern":"catch (e) {\n  if (e.response?.status === 422 && /could not be copied/.test(e.response.data?.detail))\n    notifyCorruptFlowData();\n  throw e;\n}","preventionTips":["Only mutate flow.data through the API/UI, never raw SQL","Validate imported flow JSON before writing it to the database","Snapshot immediately after importing a flow to confirm data is deepcopy-safe"],"tags":["http-422","flow-versions","deepcopy","data-corruption"],"backgroundTag":null,"analyzedSha":"976ec789d2886a86de109c044d089d68e96c9a35","analyzedAt":"2026-08-14T18:23:12.227Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}