{"record":{"id":"d0c8ea2ec4ae2eef","repo":"langflow-ai/langflow","slug":"deployment-was-deleted-from-the-provider-but-loca","errorCode":null,"errorMessage":"Deployment was deleted from the provider, but local cleanup failed. Retry the delete request.","messagePattern":"Deployment was deleted from the provider, but local cleanup failed\\. Retry the delete request\\.","errorType":"http","errorClass":"HTTPException","httpStatus":500,"severity":"error","filePath":"src/backend/base/langflow/api/v1/deployments.py","lineNumber":298,"sourceCode":"    except Exception:  # noqa: BLE001\n        await session.rollback()\n        logger.warning(\n            \"Local deployment cleanup failed for deployment %s (resource_key=%s) after provider delete; retrying.\",\n            deployment_id,\n            resource_key,\n            exc_info=True,\n        )\n        try:\n            await delete_deployment_by_id(session, user_id=user_id, deployment_id=deployment_id)\n            await session.commit()\n        except Exception as exc:\n            await session.rollback()\n            logger.exception(\n                \"Retrying local deployment cleanup failed for deployment %s (resource_key=%s) after provider delete.\",\n                deployment_id,\n                resource_key,\n            )\n            raise HTTPException(\n                status_code=status.HTTP_500_INTERNAL_SERVER_ERROR,\n                detail=\"Deployment was deleted from the provider, but local cleanup failed. Retry the delete request.\",\n            ) from exc\n\n\n@router.post(\n    \"/providers\",\n    response_model=DeploymentProviderAccountGetResponse,\n    status_code=status.HTTP_201_CREATED,\n    tags=[\"Deployment Providers\"],\n)\nasync def create_provider_account(\n    session: DbSession,\n    payload: DeploymentProviderAccountCreateRequest,\n    current_user: CurrentActiveUser,\n    telemetry: Annotated[DeploymentTelemetryCtx, Depends(provider_create_telemetry)],\n):\n    telemetry.provider = payload.provider_key","sourceCodeStart":280,"sourceCodeEnd":316,"githubUrl":"https://github.com/langflow-ai/langflow/blob/976ec789d2886a86de109c044d089d68e96c9a35/src/backend/base/langflow/api/v1/deployments.py#L280-L316","documentation":"Raised as HTTP 500 when a deployment DELETE succeeded on the provider side but the follow-up local DB cleanup (delete_deployment_by_id + commit) failed even after a retry with rollback. The state is deliberately partial: the provider resource is gone but the local row may remain, so the message explicitly tells the caller the operation is idempotent and safe to retry.","triggerScenarios":"DELETE /api/v1/deployments/{id} where the provider API delete returns success, then the local session commit fails — DB connection drop, constraint violation from concurrent references, or lock timeout during delete_deployment_by_id.","commonSituations":"Database failover or connection pool exhaustion mid-request; concurrent delete requests racing on the same deployment row; FK constraints from leftover child records (e.g. deployment logs) blocking deletion.","solutions":["Retry the exact same DELETE request — provider-side deletion already succeeded and local cleanup is idempotent.","If retry keeps failing, check DB health: connections, locks (pg_locks / SHOW PROCESSLIST), and FK constraints referencing the deployment row.","Look for the 'Retrying local deployment cleanup failed ...' log entry which includes resource_key and the DB error.","As a last resort, remove blocking child rows or drop the local record manually, then confirm GET no longer lists the deployment."],"exampleFix":"# before\nres = await client.delete(f\"/api/v1/deployments/{deployment_id}\")\nres.raise_for_status()\n\n# after\nfor attempt in range(3):\n    res = await client.delete(f\"/api/v1/deployments/{deployment_id}\")\n    if res.status_code != 500:\n        break\n    await asyncio.sleep(2 ** attempt)  # local cleanup is idempotent; safe to retry","handlingStrategy":"retry","validationCode":null,"typeGuard":null,"tryCatchPattern":"for attempt in range(3):\n    res = await client.delete(f\"/api/v1/deployments/{deployment_id}\")\n    if res.status_code != 500:\n        break\n    detail = res.json()[\"detail\"]\n    if \"Retry the delete request\" not in detail:\n        raise RuntimeError(detail)\n    await asyncio.sleep(2 ** attempt)  # provider delete already done; local cleanup is idempotent","preventionTips":["Treat this 500 as retryable by design — the message says so explicitly.","Avoid racing concurrent DELETEs on the same deployment id.","Watch DB locks/FK constraints if cleanup keeps failing after retries."],"tags":["langflow","deployments","partial-failure","idempotent-retry"],"backgroundTag":null,"analyzedSha":"976ec789d2886a86de109c044d089d68e96c9a35","analyzedAt":"2026-08-14T18:23:12.227Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}