{"record":{"id":"a8a6507947f1da3e","repo":"unslothai/unsloth","slug":"stt-model-must-be-one-of-studio-s-defaults-or-a-hu","errorCode":null,"errorMessage":"STT model must be one of Studio's defaults or a Hugging Face repository in 'owner/model' form.","messagePattern":"STT model must be one of Studio's defaults or a Hugging Face repository in 'owner/model' form\\.","errorType":"http","errorClass":"SttModelIdError","httpStatus":422,"severity":"error","filePath":"studio/backend/core/inference/stt_sidecar.py","lineNumber":309,"sourceCode":"def is_available() -> bool:\n    \"\"\"True when the complete local Whisper backend can be imported.\"\"\"\n    try:\n        ensure_stt_available()\n    except SttUnavailableError:\n        return False\n    return True\n\n\ndef resolve_model_id(model: Optional[str]) -> str:\n    \"\"\"Resolve a curated id or validate a custom Hugging Face repository.\"\"\"\n    if not model:\n        return DEFAULT_STT_MODEL\n    normalized = model.strip()\n    if normalized in STT_MODELS:\n        return normalized\n    if _HF_REPO_ID.fullmatch(normalized):\n        return normalized\n    raise SttModelIdError(\n        \"STT model must be one of Studio's defaults or a Hugging Face \"\n        \"repository in 'owner/model' form.\"\n    )\n\n\ndef resolve_model_repo(model_id: str) -> str:\n    \"\"\"Return the Hub repository for a curated or custom model id.\"\"\"\n    resolved = resolve_model_id(model_id)\n    return STT_MODELS.get(resolved, resolved)\n\n\ndef _is_whisper_config(config: object) -> bool:\n    \"\"\"True when Hub/local config metadata identifies a Whisper ASR model.\"\"\"\n    if not isinstance(config, dict):\n        return False\n    model_type = config.get(\"model_type\")\n    if isinstance(model_type, str) and model_type.strip().lower() == \"whisper\":\n        return True","sourceCodeStart":291,"sourceCodeEnd":327,"githubUrl":"https://github.com/unslothai/unsloth/blob/203007d19051dcd2ae33876786d117c99f6b0368/studio/backend/core/inference/stt_sidecar.py#L291-L327","documentation":"SttModelIdError (a ValueError) raised by resolve_model_id() when the model string is neither empty (which resolves to DEFAULT_STT_MODEL), a key of STT_MODELS (curated defaults), nor a fullmatch of the 'owner/model' Hugging Face repository regex _HF_REPO_ID.","triggerScenarios":"Passing a model like \"whisper-large-v3\" (no owner), \"openai/whisper-large-v3/extra\", \"../local/path\", or stray whitespace-surrounded invalid ids (input is stripped first, so only invalid shapes after strip fail).","commonSituations":"Users typing a bare model name instead of 'owner/model'; copy-paste with trailing slashes or fragments; frontend sending an unvalidated free-text field; API consumers passing a local path.","solutions":["Use one of the curated ids from STT_MODELS or a full 'owner/model' repository id.","Validate with resolve_model_id() (or the _HF_REPO_ID pattern) in the UI/API before submitting.","Pass empty/None to get the default model instead of an ad-hoc string."],"exampleFix":"```python\n# before\nmodel_id = request.args[\"model\"]  # e.g. \"whisper-large-v3\"\nrepo = resolve_model_repo(model_id)  # raises SttModelIdError\n\n# after\nfrom studio.backend.core.inference.stt_sidecar import resolve_model_id, SttModelIdError\n\ntry:\n    model_id = resolve_model_id(request.args.get(\"model\"))\nexcept SttModelIdError:\n    return \"Model must be a default id or 'owner/model'\", 400\n```","handlingStrategy":"validation","validationCode":"```python\nfrom studio.backend.core.inference.stt_sidecar import STT_MODELS, _HF_REPO_ID\n\ndef valid_stt_model(model: str | None) -> bool:\n    if not model:\n        return True  # default\n    n = model.strip()\n    return n in STT_MODELS or bool(_HF_REPO_ID.fullmatch(n))\n```","typeGuard":"```python\ndef is_valid_stt_model_id(model: object) -> TypeGuard[str | None]:\n    if model is None:\n        return True\n    if not isinstance(model, str):\n        return False\n    n = model.strip()\n    return not n or n in STT_MODELS or bool(_HF_REPO_ID.fullmatch(n))\n```","tryCatchPattern":"```python\ntry:\n    model_id = resolve_model_id(raw_input)\nexcept SttModelIdError:\n    return \"Use a Studio default or 'owner/model' form\", 400\n```","preventionTips":["Validate in the frontend with the same 'owner/model' rule before submit.","Offer a dropdown of curated models instead of free text.","Trim input; anything else must fullmatch the repo pattern."],"tags":["stt","validation","model-id","huggingface"],"backgroundTag":null,"analyzedSha":"203007d19051dcd2ae33876786d117c99f6b0368","analyzedAt":"2026-08-15T02:48:39.846Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}