{"record":{"id":"3ca84f1f003a3b24","repo":"langflow-ai/langflow","slug":"could-not-activate-version-the-flow-was-modified","errorCode":null,"errorMessage":"Could not activate version — the flow was modified concurrently. Please try again.","messagePattern":"Could not activate version — the flow was modified concurrently\\. Please try again\\.","errorType":"http","errorClass":"HTTPException","httpStatus":409,"severity":"error","filePath":"src/backend/base/langflow/api/v1/flow_version.py","lineNumber":297,"sourceCode":"        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\n            flow.updated_at = datetime.now(timezone.utc)\n\n            session.add(flow)\n            await session.flush()\n    except FlowVersionError as exc:\n        raise _translate_version_error(exc) from exc\n    except IntegrityError as exc:\n        raise HTTPException(\n            status_code=409,\n            detail=\"Could not activate version — the flow was modified concurrently. Please try again.\",\n        ) from exc\n    except SQLAlchemyError as exc:\n        raise HTTPException(\n            status_code=500,\n            detail=\"Database error while activating version. Please try again.\",\n        ) from exc\n\n    await logger.adebug(\"Activated version %s (%s) for flow %s\", version_id, f\"v{target_entry.version_number}\", flow_id)\n\n    return FlowRead.model_validate(flow, from_attributes=True)\n\n\n@router.delete(\"/{version_id}\", status_code=204)\nasync def delete_version_entry(\n    flow_id: UUID,\n    version_id: UUID,","sourceCodeStart":279,"sourceCodeEnd":315,"githubUrl":"https://github.com/langflow-ai/langflow/blob/976ec789d2886a86de109c044d089d68e96c9a35/src/backend/base/langflow/api/v1/flow_version.py#L279-L315","documentation":"409 from the version-activation endpoint: inside the begin_nested savepoint, session.flush() raised SQLAlchemy IntegrityError — a database-level unique/constraint violation while writing the auto-snapshot row or the updated flow. The message frames it as concurrent modification because the most common IntegrityError here is a version-number unique collision caused by a race, and the savepoint rolls everything back atomically.","triggerScenarios":"Two concurrent activations (or activation + snapshot creation) on the same flow racing to claim the next version_number; the flow row failing an optimistic-concurrency/unique constraint at flush time. The savepoint guarantees neither the auto-snapshot nor the flow overwrite persists.","commonSituations":"Double-clicked 'activate' in the UI firing two identical requests; automation retrying activation without backoff; multiple clients editing the same flow.","solutions":["Retry the activation after a short delay — one of the racing requests wins and the retry then targets a consistent state","Debounce/disable the activate button client-side to prevent duplicate submits","If it persists single-threaded, check the server log for the underlying IntegrityError and the constraint it names (could be a schema/unique-index drift after migrations)"],"exampleFix":"// before\nawait activateVersion(flowId, versionId);\n\n// after: single retry with backoff for 409\nfor (let attempt = 0; attempt < 2; attempt++) {\n  try {\n    await activateVersion(flowId, versionId);\n    break;\n  } catch (e) {\n    if (e.response?.status !== 409 || attempt === 1) throw e;\n    await sleep(500);\n  }\n}","handlingStrategy":"retry","validationCode":null,"typeGuard":null,"tryCatchPattern":"catch (e) {\n  if (e.response?.status === 409) { await sleep(backoffMs); return activateVersion(flowId, versionId); }\n  throw e;\n}","preventionTips":["Debounce activate buttons and disable during in-flight requests","Use idempotency-style single-flight wrappers for activation calls","Cap retries (1-2) and surface persistent 409s instead of looping"],"tags":["http-409","flow-versions","concurrency","activate","database"],"backgroundTag":null,"analyzedSha":"976ec789d2886a86de109c044d089d68e96c9a35","analyzedAt":"2026-08-14T18:23:12.227Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}