{"record":{"id":"cfd2afe2d4e7a73b","repo":"jamiepine/voicebox","slug":"failed-to-delete-model-str-e","errorCode":null,"errorMessage":"Failed to delete model: {str(e)}","messagePattern":"Failed to delete model: (.+?)","errorType":"http","errorClass":"HTTPException","httpStatus":500,"severity":"error","filePath":"backend/routes/models.py","lineNumber":478,"sourceCode":"        unload_model_by_config(config)\n\n        cache_dir = hf_constants.HF_HUB_CACHE\n        repo_cache_dir = Path(cache_dir) / (\"models--\" + hf_repo_id.replace(\"/\", \"--\"))\n\n        if not repo_cache_dir.exists():\n            raise HTTPException(status_code=404, detail=f\"Model {model_name} not found in cache\")\n\n        try:\n            shutil.rmtree(repo_cache_dir)\n        except OSError as e:\n            raise HTTPException(status_code=500, detail=f\"Failed to delete model cache directory: {str(e)}\")\n\n        return {\"message\": f\"Model {model_name} deleted successfully\"}\n\n    except HTTPException:\n        raise\n    except Exception as e:\n        raise HTTPException(status_code=500, detail=f\"Failed to delete model: {str(e)}\")\n","sourceCodeStart":460,"sourceCodeEnd":479,"githubUrl":"https://github.com/jamiepine/voicebox/blob/51f49dea198384b4eb6087b72c17057c6eb1c1cd/backend/routes/models.py#L460-L479","documentation":"Catch-all 500 from DELETE /models/{model_name}. After the inner OSError handler, any other Exception (non-OSError) from unload_model_by_config or the surrounding logic is caught and re-raised as HTTPException(500, detail=f'Failed to delete model: {str(e)}'). HTTPException is explicitly re-raised (except HTTPException: raise) so the 404 and inner 500 above pass through unchanged.","triggerScenarios":"unload_model_by_config raises a non-OSError exception (backend attribute error, engine dispatch failure); unexpected error building the repo_cache_dir path; HuggingFace constants import fails inside the handler; registry config object missing hf_repo_id attribute.","commonSituations":"Backend singleton in a broken state when unload is attempted; partial registry where a config lacks hf_repo_id; bug in an engine-specific unload path; corrupted cache layout triggering a non-OSError filesystem error from a helper.","solutions":["Read detail=str(e) — the forwarded message identifies the non-OSError cause.","Restart the backend to reset engine singletons, then retry the delete.","If the underlying cause is a registry/config defect (missing hf_repo_id), fix the config before retrying.","As a last resort, stop the backend and remove the cache directory manually, then restart."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try {\n  await fetch(`/models/${name}`, {method:'DELETE'});\n} catch (e) {\n  // non-OSError 500 — server-side fault; read detail but don't blindly retry\n  if (e.response?.status === 500 && /Failed to delete model:/.test(e.response.detail ?? '')) {\n    // surface to user; recommend backend restart and retry\n    throw new Error('Server error during delete — try restarting the backend');\n  }\n  throw e;\n}","preventionTips":["Surface the forwarded detail to ops for diagnosis rather than silently retrying.","Keep the backend and registry configs consistent (all configs must define hf_repo_id) to avoid attribute errors in the delete path.","Restart the backend if a delete starts failing persistently — engine singletons may be wedged."],"tags":["models","delete","http-500","catch-all","leaks-detail"],"backgroundTag":null,"analyzedSha":"51f49dea198384b4eb6087b72c17057c6eb1c1cd","analyzedAt":"2026-08-12T16:51:42.824Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}