{"record":{"id":"f59aa46c7ce1daf5","repo":"sgl-project/sglang","slug":"language-language-not-recognized-use-full-nam","errorCode":null,"errorMessage":"Language '{language}' not recognized. Use full name (e.g., 'English') or ISO 639-1 code (e.g., 'en').","messagePattern":"Language '(.+?)' not recognized\\. Use full name \\(e\\.g\\., 'English'\\) or ISO 639-1 code \\(e\\.g\\., 'en'\\)\\.","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"python/sglang/srt/multimodal/processors/whisper.py","lineNumber":127,"sourceCode":"\n    # Check if it's a full language name\n    if language_lower in LANG_NAME_TO_CODE:\n        return LANG_NAME_TO_CODE[language_lower]\n\n    # Fused autodetect's FSM regex covers the full Whisper language-token\n    # vocab (see WHISPER_LANG_TOKEN_CODES), which is wider than the\n    # English-name-keyed ISO639_1_SUPPORTED_LANGS dict. Accept any code in\n    # that wider set too so that detection -> reuse-as-input round-trips.\n    # Lazy import to avoid top-level cycle with the openai entrypoint.\n    from sglang.srt.entrypoints.openai.transcription_adapters.whisper import (\n        WHISPER_LANG_TOKEN_CODES,\n    )\n\n    if language_lower in WHISPER_LANG_TOKEN_CODES:\n        return language_lower\n\n    # Not recognized\n    raise ValueError(\n        f\"Language '{language}' not recognized. \"\n        f\"Use full name (e.g., 'English') or ISO 639-1 code (e.g., 'en').\"\n    )\n\n\nclass WhisperProcessor(BaseMultimodalProcessor):\n    models = [WhisperForConditionalGeneration]\n\n    def __init__(self, hf_config, server_args, _processor, *args, **kwargs):\n        super().__init__(hf_config, server_args, _processor, *args, **kwargs)\n        # Cache tokenizer for language token lookup\n        self._tokenizer = getattr(self._processor, \"tokenizer\", None)\n\n    def _pop_sampling_param(self, request_obj, key: str):\n        sampling_params = getattr(request_obj, \"sampling_params\", None) or {}\n        return sampling_params.pop(key, None)\n\n    def _get_language_token_id(self, language: Optional[str]) -> int:","sourceCodeStart":109,"sourceCodeEnd":145,"githubUrl":"https://github.com/sgl-project/sglang/blob/0132848349585cfe6aae51c4941cbae872505f8a/python/sglang/srt/multimodal/processors/whisper.py#L109-L145","documentation":"Whisper's normalize_language_to_code accepts a language given as a Whisper language name ('english') or an ISO 639-1 code ('en') and must resolve it to a code present in WHISPER_LANG_TOKEN_CODES. Anything else — unknown names, 3-letter ISO 639-2 codes ('eng'), regional tags ('en-US') — fails normalization and raises ValueError.","triggerScenarios":"Passing language='eng' (ISO 639-2), 'en-US' (regional suffix), or a misspelled name like 'Englsih' to WhisperProcessor.process_mm_data_async.","commonSituations":"Data pipelines storing BCP-47 or 639-2 codes; users typing locale strings with region; languages Whisper does not support at all (e.g. 'klingon').","solutions":["Use the ISO 639-1 two-letter code ('en', 'zh') or the full Whisper name ('English')","Strip regional suffixes: language.split('-')[0].lower()","Check WHISPER_LANG_TOKEN_CODES for the supported set"],"exampleFix":"# before\nlanguage='en-US'\n# after\nlanguage = language.split('-')[0].lower()  # 'en'","handlingStrategy":"validation","validationCode":"code = language.strip().lower().split('-')[0]\nif code not in WHISPER_LANG_TOKEN_CODES and code not in WHISPER_LANG_NAMES:\n    raise ValueError(f'unsupported language: {language}')","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Store ISO 639-1 codes in your data model","Normalize locale tags (strip region, lowercase) before calling the API"],"tags":["whisper","audio","language-code","validation"],"backgroundTag":"invalid-language-code","analyzedSha":"0132848349585cfe6aae51c4941cbae872505f8a","analyzedAt":"2026-08-28T05:10:05.995Z","schemaVersion":2},"datasetVersion":"2026-08-28T06:17:29.519Z"}