{"record":{"id":"540ab71caa2d71dd","repo":"unslothai/unsloth","slug":"gguf-variant-is-required-when-export-type-is-gguf","errorCode":null,"errorMessage":"gguf_variant is required when export_type is 'gguf'","messagePattern":"gguf_variant is required when export_type is 'gguf'","errorType":"http","errorClass":"HTTPException","httpStatus":400,"severity":"warning","filePath":"studio/backend/routes/models.py","lineNumber":2909,"sourceCode":"    gguf_variant: Optional[str] = Body(None),\n    current_subject: str = Depends(get_current_subject),\n):\n    \"\"\"Delete an Unsloth-trained or exported model from disk.\n\n    Only paths under Unsloth's outputs/exports roots are accepted.\n    Exported GGUF entries can delete one quant variant at a time.\n    \"\"\"\n    if source not in {\"training\", \"exported\"}:\n        raise HTTPException(\n            status_code = 400,\n            detail = \"Only trained or exported Unsloth models can be deleted\",\n        )\n\n    if not model_path or not model_path.strip():\n        raise HTTPException(status_code = 400, detail = \"model_path is required\")\n\n    if export_type == \"gguf\" and not gguf_variant:\n        raise HTTPException(\n            status_code = 400,\n            detail = \"gguf_variant is required when export_type is 'gguf'\",\n        )\n\n    raw_path = Path(model_path).expanduser()\n    if source == \"training\":\n        target_path = raw_path\n        allowed_root = outputs_root()\n    else:\n        allowed_root = exports_root()\n        target_path = (\n            raw_path.parent\n            if export_type == \"gguf\" and raw_path.suffix.lower() == \".gguf\"\n            else raw_path\n        )\n\n    allowed_root = allowed_root.resolve()\n    delete_path = Path(os.path.abspath(str(target_path)))","sourceCodeStart":2891,"sourceCodeEnd":2927,"githubUrl":"https://github.com/unslothai/unsloth/blob/203007d19051dcd2ae33876786d117c99f6b0368/studio/backend/routes/models.py#L2891-L2927","documentation":"Thrown by DELETE /delete-finetuned when export_type is \"gguf\" but gguf_variant is absent/empty. GGUF exports can hold several quantization variants (Q4_K_M, Q8_0, ...) side by side in one export directory, so the endpoint deletes one variant at a time and refuses to guess. The check happens before any path validation, so nothing is modified.","triggerScenarios":"Body {\"model_path\": \"/exports/my-model-gguf\", \"source\": \"exported\", \"export_type\": \"gguf\"} with no gguf_variant; or gguf_variant: \"\" / null. Passing export_type: \"gguf\" while source: \"training\" also hits this because the gguf branch is keyed only on export_type.","commonSituations":"Frontend delete dialog forwards export_type from the row but drops the variant selector when the user clicks too fast; API scripts written before per-variant GGUF deletion was introduced (older versions deleted the whole directory); confusing export_type: \"gguf\" with a generic type tag.","solutions":["Include the quant variant: {\"model_path\": \"/exports/my-model-gguf\", \"source\": \"exported\", \"export_type\": \"gguf\", \"gguf_variant\": \"Q4_K_M\"}.","If you actually want the whole export directory gone, omit export_type (or set it to a non-gguf value) so the directory delete path runs.","Pick the variant from the UI row / scan result rather than hardcoding, since only variants actually present on disk can be deleted (see the 404 'Variant ... not found on disk')."],"exampleFix":"# before\nrequests.delete('/delete-finetuned', json={'model_path': p, 'source': 'exported', 'export_type': 'gguf'})\n# after\nrequests.delete('/delete-finetuned', json={'model_path': p, 'source': 'exported', 'export_type': 'gguf', 'gguf_variant': 'Q4_K_M'})","handlingStrategy":"validation","validationCode":"if (payload.export_type === 'gguf' && !(payload.gguf_variant ?? '').trim()) {\n  throw new Error(\"gguf_variant is required when export_type is 'gguf'\");\n}","typeGuard":"function isCompleteGgufDelete(payload) {\n  return payload.export_type !== 'gguf' || typeof payload.gguf_variant === 'string' && payload.gguf_variant.trim().length > 0;\n}","tryCatchPattern":null,"preventionTips":["In the UI, make the quant variant a required selector when the row's export_type is gguf.","Default scripts to whole-directory delete (omit export_type) unless per-variant deletion is explicitly wanted.","Pass the variant exactly as advertised by the export scan (e.g. Q4_K_M)."],"tags":["fastapi","unsloth","gguf","validation","quantization","model-deletion"],"backgroundTag":null,"analyzedSha":"203007d19051dcd2ae33876786d117c99f6b0368","analyzedAt":"2026-08-15T02:48:39.846Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}