{"record":{"id":"2541dbf5321e8959","repo":"jamiepine/voicebox","slug":"unknown-model-size-model-size-2541db","errorCode":null,"errorMessage":"Unknown model size: {model_size}","messagePattern":"Unknown model size: (.+?)","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"backend/backends/qwen_custom_voice_backend.py","lineNumber":75,"sourceCode":"\nclass QwenCustomVoiceBackend:\n    \"\"\"Qwen3-TTS CustomVoice backend — preset speakers with instruct control.\"\"\"\n\n    def __init__(self, model_size: str = \"1.7B\"):\n        self.model = None\n        self.model_size = model_size\n        self.device = self._get_device()\n        self._current_model_size: Optional[str] = None\n\n    def _get_device(self) -> str:\n        return get_torch_device(allow_xpu=True, allow_directml=True)\n\n    def is_loaded(self) -> bool:\n        return self.model is not None\n\n    def _get_model_path(self, model_size: str) -> str:\n        if model_size not in QWEN_CV_HF_REPOS:\n            raise ValueError(f\"Unknown model size: {model_size}\")\n        return QWEN_CV_HF_REPOS[model_size]\n\n    def _is_model_cached(self, model_size: Optional[str] = None) -> bool:\n        size = model_size or self.model_size\n        return is_model_cached(self._get_model_path(size))\n\n    async def load_model_async(self, model_size: Optional[str] = None) -> None:\n        if model_size is None:\n            model_size = self.model_size\n\n        if self.model is not None and self._current_model_size == model_size:\n            return\n\n        if self.model is not None and self._current_model_size != model_size:\n            self.unload_model()\n\n        await asyncio.to_thread(self._load_model_sync, model_size)\n","sourceCodeStart":57,"sourceCodeEnd":93,"githubUrl":"https://github.com/jamiepine/voicebox/blob/51f49dea198384b4eb6087b72c17057c6eb1c1cd/backend/backends/qwen_custom_voice_backend.py#L57-L93","documentation":"Raised by QwenCustomVoiceBackend._get_model_path when model_size is not a key of QWEN_CV_HF_REPOS, which only contains \"1.7B\" (Qwen/Qwen3-TTS-12Hz-1.7B-CustomVoice) and \"0.6B\" (Qwen/Qwen3-TTS-12Hz-0.6B-CustomVoice). Used to look up the CustomVoice (preset-speaker) variant of Qwen3-TTS.","triggerScenarios":"Instantiating QwenCustomVoiceBackend(model_size=...) or calling load_model_async on it with anything other than \"1.7B\" or \"0.6B\".","commonSituations":"Treating CustomVoice as accepting the same set as the LLM backend; passing a TTS base-engine size through unchanged when the user picked the custom-voice engine; case/whitespace drift from the MCP engine arg.","solutions":["Pass \"1.7B\" (default) or \"0.6B\" to the custom-voice engine.","Validate the size against QWEN_CV_HF_REPOS keys before forwarding.","If the MCP caller sent an unsupported size, map it to the engine default rather than raising."],"exampleFix":"// before\nqwen_custom_voice_backend.load_model_async(model_size=\"4B\")\n// after\nqwen_custom_voice_backend.load_model_async(model_size=\"1.7B\")","handlingStrategy":"validation","validationCode":"from backend.backends.qwen_custom_voice_backend import QWEN_CV_HF_REPOS\nif model_size not in QWEN_CV_HF_REPOS:\n    raise ValueError(f\"model_size must be one of {sorted(QWEN_CV_HF_REPOS)}\")\nawait cv_backend.load_model_async(model_size=model_size)","typeGuard":"def is_qwen_cv_size(value: str) -> bool:\n    from backend.backends.qwen_custom_voice_backend import QWEN_CV_HF_REPOS\n    return isinstance(value, str) and value in QWEN_CV_HF_REPOS","tryCatchPattern":"try:\n    await cv_backend.load_model_async(model_size=model_size)\nexcept ValueError as exc:\n    if \"Unknown model size\" in str(exc):\n        await cv_backend.load_model_async(model_size=\"1.7B\")\n    else:\n        raise","preventionTips":["Import the canonical QWEN_CV_HF_REPOS and validate against its keys rather than hardcoding.","When an MCP caller picks the custom-voice engine, re-validate the size against that engine's set.","Map unknown sizes to the engine default in the MCP layer instead of letting the backend raise."],"tags":["qwen-custom-voice","model-selection","validation","qwen-tts"],"backgroundTag":null,"analyzedSha":"51f49dea198384b4eb6087b72c17057c6eb1c1cd","analyzedAt":"2026-08-12T16:51:42.824Z","schemaVersion":2},"datasetVersion":"2026-08-12T18:17:37.767Z"}