{"record":{"id":"511c6d117a02d6f5","repo":"jamiepine/voicebox","slug":"unknown-model-size-model-size-511c6d","errorCode":null,"errorMessage":"Unknown model size: {model_size}","messagePattern":"Unknown model size: (.+?)","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"backend/backends/pytorch_backend.py","lineNumber":59,"sourceCode":"        return self.model is not None\n\n    def _get_model_path(self, model_size: str) -> str:\n        \"\"\"\n        Get the HuggingFace Hub model ID.\n\n        Args:\n            model_size: Model size (1.7B or 0.6B)\n\n        Returns:\n            HuggingFace Hub model ID\n        \"\"\"\n        hf_model_map = {\n            \"1.7B\": \"Qwen/Qwen3-TTS-12Hz-1.7B-Base\",\n            \"0.6B\": \"Qwen/Qwen3-TTS-12Hz-0.6B-Base\",\n        }\n\n        if model_size not in hf_model_map:\n            raise ValueError(f\"Unknown model size: {model_size}\")\n\n        return hf_model_map[model_size]\n\n    def _is_model_cached(self, model_size: str) -> bool:\n        return is_model_cached(self._get_model_path(model_size))\n\n    async def load_model_async(self, model_size: Optional[str] = None):\n        \"\"\"\n        Lazy load the TTS model with automatic downloading from HuggingFace Hub.\n\n        Args:\n            model_size: Model size to load (1.7B or 0.6B)\n        \"\"\"\n        if model_size is None:\n            model_size = self.model_size\n\n        # If already loaded with correct size, return\n        if self.model is not None and self._current_model_size == model_size:","sourceCodeStart":41,"sourceCodeEnd":77,"githubUrl":"https://github.com/jamiepine/voicebox/blob/51f49dea198384b4eb6087b72c17057c6eb1c1cd/backend/backends/pytorch_backend.py#L41-L77","documentation":"Raised by PyTorchTTSBackend._get_model_path when model_size is not in hf_model_map, whose only keys are \"1.7B\" (Qwen/Qwen3-TTS-12Hz-1.7B-Base) and \"0.6B\" (Qwen/Qwen3-TTS-12Hz-0.6B-Base). The map maps a size token to the HuggingFace Hub repo for the PyTorch Qwen3-TTS base weights.","triggerScenarios":"Calling load_model_async or _get_model_path with a value other than \"1.7B\" or \"0.6B\" — e.g. \"4B\", lowercase \"1.7b\", or \"large\".","commonSituations":"Sharing one model-size constant across engines where only some accept it; passing the LLM backend's \"4B\" to the TTS backend; untrimmed UI input; mistaking whisper-style names (\"base\"/\"turbo\") for TTS sizes.","solutions":["Use \"1.7B\" or \"0.6B\" exactly.","Whitelist/normalize at the API boundary so the backend only ever sees valid tokens.","Keep TTS size constants separate from LLM size constants to avoid \"4B\" leaking through."],"exampleFix":"// before\nbackend.load_model_async(model_size=\"4B\")\n// after\nbackend.load_model_async(model_size=\"0.6B\")","handlingStrategy":"validation","validationCode":"PYTORCH_TTS_SIZES = {\"1.7B\", \"0.6B\"}\nif model_size not in PYTORCH_TTS_SIZES:\n    raise ValueError(f\"model_size must be one of {sorted(PYTORCH_TTS_SIZES)}\")\nawait backend.load_model_async(model_size=model_size)","typeGuard":"def is_pytorch_tts_size(value: str) -> bool:\n    return isinstance(value, str) and value in {\"1.7B\", \"0.6B\"}","tryCatchPattern":"try:\n    await backend.load_model_async(model_size=model_size)\nexcept ValueError as exc:\n    if \"Unknown model size\" in str(exc):\n        model_size = \"1.7B\"\n        await backend.load_model_async(model_size=model_size)\n    else:\n        raise","preventionTips":["Validate size at the MCP/engine boundary, not just inside the backend.","Treat TTS and LLM size enums as separate constants.","Surface the allowed set in the error message your caller sees."],"tags":["pytorch","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"}