langflow-ai/langflow · error · HTTPException
Deployment was deleted from the provider, but local cleanup
Error message
Deployment was deleted from the provider, but local cleanup failed. Retry the delete request.
What it means
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.
Source
Thrown at src/backend/base/langflow/api/v1/deployments.py:298
except Exception: # noqa: BLE001
await session.rollback()
logger.warning(
"Local deployment cleanup failed for deployment %s (resource_key=%s) after provider delete; retrying.",
deployment_id,
resource_key,
exc_info=True,
)
try:
await delete_deployment_by_id(session, user_id=user_id, deployment_id=deployment_id)
await session.commit()
except Exception as exc:
await session.rollback()
logger.exception(
"Retrying local deployment cleanup failed for deployment %s (resource_key=%s) after provider delete.",
deployment_id,
resource_key,
)
raise HTTPException(
status_code=status.HTTP_500_INTERNAL_SERVER_ERROR,
detail="Deployment was deleted from the provider, but local cleanup failed. Retry the delete request.",
) from exc
@router.post(
"/providers",
response_model=DeploymentProviderAccountGetResponse,
status_code=status.HTTP_201_CREATED,
tags=["Deployment Providers"],
)
async def create_provider_account(
session: DbSession,
payload: DeploymentProviderAccountCreateRequest,
current_user: CurrentActiveUser,
telemetry: Annotated[DeploymentTelemetryCtx, Depends(provider_create_telemetry)],
):
telemetry.provider = payload.provider_keyView on GitHub (pinned to 976ec789d2)
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.
Example fix
# before
res = await client.delete(f"/api/v1/deployments/{deployment_id}")
res.raise_for_status()
# after
for attempt in range(3):
res = await client.delete(f"/api/v1/deployments/{deployment_id}")
if res.status_code != 500:
break
await asyncio.sleep(2 ** attempt) # local cleanup is idempotent; safe to retry Defensive patterns
Strategy: retry
Try / catch
for attempt in range(3):
res = await client.delete(f"/api/v1/deployments/{deployment_id}")
if res.status_code != 500:
break
detail = res.json()["detail"]
if "Retry the delete request" not in detail:
raise RuntimeError(detail)
await asyncio.sleep(2 ** attempt) # provider delete already done; local cleanup is idempotent Prevention
- 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.
When it happens
Trigger: 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.
Common situations: 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.
Related errors
- Provider account is already tracked by user.
- Deployment name is required
- Job not found: {exc!s}
- Graph not found
- parse_exception(exc)
AI-assisted analysis of langflow-ai/langflow@976ec789d2 (2026-08-14).
Data as JSON: /api/errors/d0c8ea2ec4ae2eef.
Report an issue: GitHub.