jamiepine/voicebox · warning · HTTPException
Model {model_name} not found in cache
Error message
Model {model_name} not found in cache What it means
404 from DELETE /models/{model_name}. The config was resolved successfully (so the id is valid) but the on-disk cache directory Path(HF_HUB_CACHE)/('models--' + hf_repo_id.replace('/','--')) does not exist. This means the model was never downloaded, the cache was already cleared, or the repo_id-to-directory translation doesn't match what's on disk.
Source
Thrown at backend/routes/models.py:466
async def delete_model(model_name: str):
"""Delete a downloaded model from the HuggingFace cache."""
from huggingface_hub import constants as hf_constants
from ..backends import get_model_config, unload_model_by_config
config = get_model_config(model_name)
if not config:
raise HTTPException(status_code=400, detail=f"Unknown model: {model_name}")
hf_repo_id = config.hf_repo_id
try:
unload_model_by_config(config)
cache_dir = hf_constants.HF_HUB_CACHE
repo_cache_dir = Path(cache_dir) / ("models--" + hf_repo_id.replace("/", "--"))
if not repo_cache_dir.exists():
raise HTTPException(status_code=404, detail=f"Model {model_name} not found in cache")
try:
shutil.rmtree(repo_cache_dir)
except OSError as e:
raise HTTPException(status_code=500, detail=f"Failed to delete model cache directory: {str(e)}")
return {"message": f"Model {model_name} deleted successfully"}
except HTTPException:
raise
except Exception as e:
raise HTTPException(status_code=500, detail=f"Failed to delete model: {str(e)}")
View on GitHub (pinned to 51f49dea19)
Solutions
- GET /models/status and check the 'downloaded' flag for that model — if false, there's nothing to delete.
- If you expected files there, GET /models/cache-dir and inspect the models--* directories on disk.
- If the repo_id was renamed, either rename the on-disk directory to match the new id or re-download.
- Treat 404 here as 'already clean' if your goal is just to ensure removal.
Example fix
# before — deleting a model that was never downloaded curl -X DELETE http://localhost:8000/models/qwen3-4b # -> 404 # after — confirm presence first GET /models/status # downloaded:false -> nothing to delete; no API call needed
Defensive patterns
Strategy: validation
Validate before calling
async function deleteIfDownloaded(name: string) {
const status = await (await fetch('/models/status')).json();
const m = status.models.find(x => x.model_name === name);
if (!m) throw new Error(`Unknown model: ${name}`);
if (!m.downloaded) return { nothingToDo: true };
return await fetch(`/models/${encodeURIComponent(name)}`, {method:'DELETE'});
} Try / catch
try {
await fetch(`/models/${name}`, {method:'DELETE'});
} catch (e) {
if (e.response?.status === 404 && /not found in cache/.test(e.response.detail)) return; // already clean
throw e;
} Prevention
- Hide or disable delete for models whose downloaded flag is false.
- Treat the 404-in-cache response as success when ensuring removal.
- After a successful delete, refresh /models/status to update the downloaded flag client-side.
When it happens
Trigger: DELETE /models/qwen3-1.7b when the 1.7B model was never downloaded; deleting again after a successful delete; cache moved/migrated away; hf_repo_id changed so the computed directory name no longer matches the existing folder.
Common situations: User clicks delete on a model the status UI shows as 'not downloaded'; double-delete; HF cache cleared out of band (rm -rf) or migrated to another volume; registry's hf_repo_id edited after downloads happened under the old id.
Related errors
- Current model cache directory not found
- Failed to delete model cache directory: {str(e)}
- Failed to delete model: {str(e)}
- Failed to fetch model info: ${response.status}
- Source version not found
AI-assisted analysis of jamiepine/voicebox@51f49dea19 (2026-08-12).
Data as JSON: /api/errors/d36c32280c9b4984.
Report an issue: GitHub.