{"record":{"id":"189c7491d69a309d","repo":"unslothai/unsloth","slug":"a-transformers-installation-is-replacing-the-lates-189c74","errorCode":null,"errorMessage":"A transformers installation is replacing the latest sidecar; retry when it completes.","messagePattern":"A transformers installation is replacing the latest sidecar; retry when it completes\\.","errorType":"http","errorClass":"HTTPException","httpStatus":409,"severity":"warning","filePath":"studio/backend/routes/export.py","lineNumber":115,"sourceCode":"            load_in_4bit = request.load_in_4bit,\n            trust_remote_code = request.trust_remote_code,\n            approved_remote_code_fingerprint = request.approved_remote_code_fingerprint,\n            hf_token = request.hf_token,\n            subject = current_subject,\n        )\n\n        if not success:\n            raise HTTPException(status_code = 400, detail = message)\n\n        return ExportOperationResponse(success = True, message = message)\n    except HTTPException:\n        raise\n    except Exception as e:\n        from utils.transformers_version import SidecarSwapInProgress\n\n        if isinstance(e, SidecarSwapInProgress):\n            # Expected loss of the race against a sidecar install: retryable 409.\n            raise HTTPException(status_code = 409, detail = str(e))\n        logger.error(f\"Error loading checkpoint: {e}\", exc_info = True)\n        raise HTTPException(\n            status_code = 500,\n            detail = \"Failed to load checkpoint\",\n        )\n\n\n@router.post(\"/cleanup\", response_model = ExportOperationResponse)\nasync def cleanup_export_memory(current_subject: str = Depends(get_current_subject)):\n    \"\"\"Cleanup export-related models from memory (ExportBackend.cleanup_memory).\"\"\"\n    try:\n        backend = get_export_backend()\n        success = await asyncio.to_thread(backend.cleanup_memory)\n\n        if not success:\n            raise HTTPException(\n                status_code = 500,\n                detail = \"Memory cleanup failed. See server logs for details.\",","sourceCodeStart":97,"sourceCodeEnd":133,"githubUrl":"https://github.com/unslothai/unsloth/blob/203007d19051dcd2ae33876786d117c99f6b0368/studio/backend/routes/export.py#L97-L133","documentation":"HTTP 409 raised when load_checkpoint loses the race against a sidecar install: the generic exception handler catches SidecarSwapInProgress from utils.transformers_version and converts it into a retryable conflict. Unlike the up-front 409 (error 1065), this one fires when the swap starts after the request passed the pre-check — the worker hit the half-replaced .venv_t5_latest mid-flight.","triggerScenarios":"A transformers install begins between _ensure_export_supported() passing and backend.load_checkpoint touching the sidecar; the loader then observes the venv being renamed/replaced and raises SidecarSwapInProgress.","commonSituations":"Two operators (or a UI plus a script) using the system at once; an install triggered automatically right as a queued export starts; CI pipelines that upgrade and export concurrently.","solutions":["Retry the request after the install completes — this 409 is explicitly documented as expected and retryable.","Add a client-side check on install status before retrying so you do not hammer the endpoint mid-install.","Operationally, avoid starting installs while exports are queued."],"exampleFix":null,"handlingStrategy":"retry","validationCode":null,"typeGuard":null,"tryCatchPattern":"try {\n  await api.post('/export/load-checkpoint', body);\n} catch (e) {\n  if (e.status === 409 && /replacing the latest sidecar/.test(e.detail)) {\n    await waitForInstallCompletion(); return retry();\n  }\n  throw e;\n}","preventionTips":["Distinguish the two 409s: pre-check (1065) vs mid-flight sidecar swap (1068) — both retry after install completes.","Serialize installs and exports operationally so this race cannot occur."],"tags":["concurrency","http-409","retryable","race-condition","export"],"backgroundTag":null,"analyzedSha":"203007d19051dcd2ae33876786d117c99f6b0368","analyzedAt":"2026-08-15T02:48:39.846Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}