{"record":{"id":"a71f8b61c4fbbc89","repo":"sgl-project/sglang","slug":"unknown-separator-style-template-sep-style","errorCode":null,"errorMessage":"Unknown separator style: {template['sep_style']}","messagePattern":"Unknown separator style: (.+?)","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"python/sglang/srt/parser/template_manager.py","lineNumber":291,"sourceCode":"        self._jinja_template_content_format = detect_jinja_template_content_format(\n            chat_template\n        )\n        logger.info(\n            f\"Detected user specified Jinja chat template with content format: {self._jinja_template_content_format}\"\n        )\n\n    def _load_json_chat_template(self, template_path: str) -> None:\n        \"\"\"Load a JSON chat template file.\"\"\"\n        assert template_path.endswith(\n            \".json\"\n        ), \"unrecognized format of chat template file\"\n\n        with open(template_path, \"r\") as filep:\n            template = json.load(filep)\n            try:\n                sep_style = SeparatorStyle[template[\"sep_style\"]]\n            except KeyError:\n                raise ValueError(\n                    f\"Unknown separator style: {template['sep_style']}\"\n                ) from None\n\n            register_conv_template(\n                Conversation(\n                    name=template[\"name\"],\n                    system_template=template[\"system\"] + \"\\n{system_message}\",\n                    system_message=template.get(\"system_message\", \"\"),\n                    roles=(template[\"user\"], template[\"assistant\"]),\n                    sep_style=sep_style,\n                    sep=template.get(\"sep\", \"\\n\"),\n                    stop_str=template[\"stop_str\"],\n                ),\n                override=True,\n            )\n        self._chat_template_name = template[\"name\"]\n\n    def _load_json_completion_template(self, template_path: str) -> None:","sourceCodeStart":273,"sourceCodeEnd":309,"githubUrl":"https://github.com/sgl-project/sglang/blob/0132848349585cfe6aae51c4941cbae872505f8a/python/sglang/srt/parser/template_manager.py#L273-L309","documentation":"When loading a JSON chat template file, the 'sep_style' string is used as a key into the SeparatorStyle enum. An unknown key raises this ValueError. Note template['sep_style'] is accessed directly, so a missing key surfaces as a plain KeyError instead.","triggerScenarios":"A custom JSON chat template containing \"sep_style\": \"ADD_COLON_SINGLE\" (or any string not a SeparatorStyle member) being loaded via _load_explicit_chat_template.","commonSituations":"Porting conv templates from fastchat versions where sep_style names differ (e.g. plain string styles like 'single' vs enum names), or hand-edited JSON with a typo.","solutions":["Use an exact SeparatorStyle enum member name (inspect the enum in sglang/srt/conversation.py)","If porting from fastchat, map legacy string styles to the enum names","Prefer .jinja templates over JSON conv templates for new setups"],"exampleFix":"// before\n{\"name\": \"mytmpl\", \"sep_style\": \"single\", ...}\n// after\n{\"name\": \"mytmpl\", \"sep_style\": \"SeparatorStyle.ADD_COLON_SINGLE\", ...}  // or exact enum member name e.g. \"ADD_COLON_SINGLE\"","handlingStrategy":"validation","validationCode":"import json\nfrom sglang.srt.conversation import SeparatorStyle\n\ntpl = json.load(open(path))\nassert tpl[\"sep_style\"] in SeparatorStyle.__members__, f\"bad sep_style {tpl['sep_style']}; valid: {list(SeparatorStyle.__members__)}\"","typeGuard":"def has_valid_sep_style(tpl: dict) -> TypeGuard[dict]:\n    from sglang.srt.conversation import SeparatorStyle\n    return isinstance(tpl.get(\"sep_style\"), str) and tpl[\"sep_style\"] in SeparatorStyle.__members__","tryCatchPattern":"try:\n    tm._load_explicit_chat_template(tokenizer_manager, path)\nexcept ValueError as e:\n    if \"Unknown separator style\" in str(e):\n        fix_sep_style_enum_name(path)  # edit JSON, retry\n    else:\n        raise","preventionTips":["Use enum member names exactly as defined in SeparatorStyle","Prefer .jinja chat templates over JSON conv templates","Validate JSON templates against the expected schema in a lint step"],"tags":["chat-template","json-template","sep-style","enum-key"],"backgroundTag":"invalid-template-config","analyzedSha":"0132848349585cfe6aae51c4941cbae872505f8a","analyzedAt":"2026-08-28T05:10:05.995Z","schemaVersion":2},"datasetVersion":"2026-08-28T06:17:29.519Z"}