{"record":{"id":"e2ead78c7483fb43","repo":"unslothai/unsloth","slug":"unknown-model-kind-model-kind-expected-one-of","errorCode":null,"errorMessage":"Unknown model_kind '{model_kind}'. Expected one of {sorted(_MODEL_KINDS)}.","messagePattern":"Unknown model_kind '(.+?)'\\. Expected one of (.+?)\\.","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"studio/backend/core/inference/diffusion.py","lineNumber":263,"sourceCode":"    where = f\"https://huggingface.co/{repo}\" if repo else \"its Hugging Face page\"\n    subject = repo or \"This model\"\n    if had_token:\n        # A token was sent and still bounced, so the account itself lacks access.\n        return f\"{subject} is gated and this Hugging Face account is not on its access list. Request access at {where}, then load again.\"\n    return f\"{subject} is gated. Request access at {where}, then add a Hugging Face token in Settings and load again.\"\n\n\ndef resolve_model_kind(gguf_filename: Optional[str], model_kind: Optional[str] = None) -> str:\n    \"\"\"Classify a load request into one of ``_MODEL_KINDS``.\n\n    An explicit ``model_kind`` wins (validated). Otherwise the kind is inferred from\n    the single-file name: a ``.gguf`` name is ``\"gguf\"``, any other single-file name is\n    ``\"single_file\"``, and the absence of a name is a full ``\"pipeline\"`` load. Pure and\n    network-free, so the route, validation, and load paths all agree on the kind.\"\"\"\n    if model_kind:\n        kind = model_kind.strip().lower()\n        if kind not in _MODEL_KINDS:\n            raise ValueError(\n                f\"Unknown model_kind '{model_kind}'. Expected one of {sorted(_MODEL_KINDS)}.\"\n            )\n        return kind\n    name = (gguf_filename or \"\").strip()\n    if not name:\n        return \"pipeline\"\n    if name.lower().endswith(\".gguf\"):\n        return \"gguf\"\n    return \"single_file\"\n\n\ndef _active_lora_pairs(pipe: Any) -> list:\n    \"\"\"``[(name, weight)]`` for the adapters actually attached to ``pipe``, zero-weight ones\n    dropped.\n\n    Reads the ``_unsloth_loras`` marker, which the LoRA paths write as ``(name, path, weight)``.\n    Shape is tolerated rather than assumed: this runs inside the generate result and an unpacking\n    error here would sink a finished generation whose images are already in hand.\"\"\"","sourceCodeStart":245,"sourceCodeEnd":281,"githubUrl":"https://github.com/unslothai/unsloth/blob/203007d19051dcd2ae33876786d117c99f6b0368/studio/backend/core/inference/diffusion.py#L245-L281","documentation":"Raised by resolve_model_kind in the diffusion module when an explicit model_kind string is passed but, after strip().lower(), it is not one of _MODEL_KINDS (which include at least 'pipeline', 'gguf', 'single_file'). It is a request-validation error: the client-supplied kind must match the module's vocabulary exactly.","triggerScenarios":"POSTing a diffusion load request with model_kind like 'diffusers', 'ckpt', 'gguf-file', or a typo/'GGUF ' variant that lowercases fine but a misspelled value; client and backend versions disagreeing on the allowed kinds.","commonSituations":"Frontend deployed ahead of/behind the backend so it sends a new or old kind name; hand-written API calls guessing the enum; stale cached form state after the vocabulary changed.","solutions":["Use one of the exact values listed in the error message (it prints sorted(_MODEL_KINDS))","Omit model_kind entirely to let it infer from gguf_filename: '.gguf' name → 'gguf', other name → 'single_file', no name → 'pipeline'","Align client and backend versions so the enum vocabulary matches"],"exampleFix":"# before\n{\"model_kind\": \"diffusers\", \"repo_id\": \"...\"}\n\n# after\n{\"model_kind\": \"pipeline\", \"repo_id\": \"...\"}","handlingStrategy":"validation","validationCode":"MODEL_KINDS = {\"pipeline\", \"gguf\", \"single_file\"}  # mirror _MODEL_KINDS\ndef valid_model_kind(kind: str | None) -> bool:\n    return kind is None or kind.strip().lower() in MODEL_KINDS","typeGuard":"def is_model_kind(v: str) -> bool:\n    import typing\n    return isinstance(v, str) and v.strip().lower() in {\"pipeline\", \"gguf\", \"single_file\"}","tryCatchPattern":"try:\n    kind = resolve_model_kind(gguf_filename, model_kind)\nexcept ValueError as e:\n    if \"Unknown model_kind\" in str(e):\n        return JSONResponse(status_code=422, content={\"detail\": str(e)})","preventionTips":["Let the server infer the kind from gguf_filename instead of sending one","Fetch the allowed kinds from the API schema rather than hardcoding","Keep frontend and backend enum vocabularies in sync on deploy"],"tags":["diffusion","validation","model-kind","api-contract"],"backgroundTag":null,"analyzedSha":"203007d19051dcd2ae33876786d117c99f6b0368","analyzedAt":"2026-08-15T02:48:39.846Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}