{"record":{"id":"5e459c7de63f3537","repo":"langflow-ai/langflow","slug":"flow-s-with-the-following-ids-already-exist-con","errorCode":null,"errorMessage":"Flow(s) with the following IDs already exist: {conflict}. Use the update endpoint or upload_file() for upsert semantics.","messagePattern":"Flow\\(s\\) with the following IDs already exist: (.+?)\\. Use the update endpoint or upload_file\\(\\) for upsert semantics\\.","errorType":"http","errorClass":"HTTPException","httpStatus":422,"severity":"error","filePath":"src/backend/base/langflow/api/v1/flows.py","lineNumber":622,"sourceCode":"    for flow in flow_list.flows:\n        await ensure_flow_permission(\n            current_user,\n            FlowAction.CREATE,\n            workspace_id=flow.workspace_id,\n            folder_id=flow.folder_id,\n        )\n    # Guard against duplicate IDs up-front so callers get a clean 422 instead\n    # of an unhandled DB IntegrityError.  Use upload_file() for upsert semantics.\n    requested_ids = [f.id for f in flow_list.flows if f.id is not None]\n    if requested_ids:\n        existing_ids = (await session.exec(select(Flow.id).where(col(Flow.id).in_(requested_ids)))).all()\n        if existing_ids:\n            conflict = \", \".join(str(i) for i in existing_ids)\n            msg = (\n                f\"Flow(s) with the following IDs already exist: {conflict}. \"\n                \"Use the update endpoint or upload_file() for upsert semantics.\"\n            )\n            raise HTTPException(status_code=422, detail=msg)\n\n    db_flows = []\n    for flow in flow_list.flows:\n        flow.user_id = current_user.id\n        # Exclude id from model_validate (same reasoning as _new_flow) and apply separately.\n        db_flow = Flow.model_validate(flow.model_dump(exclude={\"id\"}))\n        if flow.id is not None:\n            db_flow.id = flow.id\n        session.add(db_flow)\n        db_flows.append(db_flow)\n\n    await session.flush()\n    for db_flow in db_flows:\n        await session.refresh(db_flow)\n\n    return [FlowRead.model_validate(db_flow, from_attributes=True) for db_flow in db_flows]\n\n","sourceCodeStart":604,"sourceCodeEnd":640,"githubUrl":"https://github.com/langflow-ai/langflow/blob/976ec789d2886a86de109c044d089d68e96c9a35/src/backend/base/langflow/api/v1/flows.py#L604-L640","documentation":"Error \"Flow(s) with the following IDs already exist: {conflict}. Use the update endpoint or upload_file() for upsert semantics.\" thrown in langflow-ai/langflow.","triggerScenarios":"Occurs when uploading/importing flows whose IDs already exist in the database without using the update endpoint or upsert semantics.","commonSituations":"See trigger scenarios.","solutions":["Use the update endpoint (PATCH) for flows that already exist, or upload with upsert semantics via upload_file().","Remove the conflicting ids from the import payload."],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"976ec789d2886a86de109c044d089d68e96c9a35","analyzedAt":"2026-08-14T18:23:12.227Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}