langflow-ai/langflow · error · HTTPException

Flow data could not be copied. The data may be corrupted.

Error message

Flow data could not be copied. The data may be corrupted.

What it means

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.

Source

Thrown at src/backend/base/langflow/api/v1/flow_version.py:271

    )

    # Verify version entry belongs to this flow
    try:
        target_entry = await get_flow_version_entry_or_raise(session, version_id, current_user.id, flow_id=flow_id)
    except FlowVersionNotFoundError as exc:
        raise HTTPException(status_code=404, detail="Version entry not found") from exc

    # Guard against activating a version with no data (check before auto-snapshot)
    if target_entry.data is None:
        raise HTTPException(status_code=400, detail="Cannot activate a version with no data")

    # Capture copies of both data dicts before the savepoint to avoid stale
    # reads if pruning inside create_flow_version_entry deletes old entries.
    try:
        current_data = copy.deepcopy(flow.data) if save_draft else None
        target_data = copy.deepcopy(target_entry.data)
    except Exception as exc:
        raise HTTPException(
            status_code=422,
            detail="Flow data could not be copied. The data may be corrupted.",
        ) from exc

    # Wrap auto-snapshot + flow overwrite in a single savepoint for atomicity.
    # If the flow update fails, the auto-snapshot is also rolled back.
    try:
        async with session.begin_nested():
            if save_draft and current_data is not None:
                await create_flow_version_entry(
                    session,
                    flow_id=flow.id,
                    user_id=current_user.id,
                    data=current_data,
                    description=f"Auto-saved before activating v{target_entry.version_number}",
                )

            flow.data = target_data

View on GitHub (pinned to 976ec789d2)

Solutions

  1. 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
  2. Re-save the flow from the UI to normalise flow.data, then retry activation
  3. For a corrupt version entry, delete it and rely on another version, or repair its data column from an export
Defensive patterns

Strategy: try-catch

Validate before calling

await axios.post(`/api/v1/flows/${flowId}/versions/`); // if this succeeds, flow.data is fine; failure localises corruption

Try / catch

catch (e) {
  if (e.response?.status === 422 && /could not be copied/.test(e.response.data?.detail))
    notifyDataCorruption('flow or version data');
  throw e;
}

Prevention

When it happens

Trigger: 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.

Common situations: Externally imported or SQL-edited flow/version rows; restored databases with serialization artifacts.

Related errors


AI-assisted analysis of langflow-ai/langflow@976ec789d2 (2026-08-14). Data as JSON: /api/errors/6d97bf95b9468e47. Report an issue: GitHub.