{"record":{"id":"73407b0d5a0663e7","repo":"sgl-project/sglang","slug":"invalid-style-self-sep-style","errorCode":null,"errorMessage":"Invalid style: {self.sep_style}","messagePattern":"Invalid style: (.+?)","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"python/sglang/srt/parser/conversation.py","lineNumber":413,"sourceCode":"                    else:\n                        ret += message + self.sep\n                else:\n                    ret += role + \": \"  # must be end with a space\n            return ret\n        elif self.sep_style == SeparatorStyle.UNLIMITED_OCR:\n            seps = [self.sep, self.sep2]\n            if system_prompt == \"\" or system_prompt is None:\n                ret = \"\"\n            else:\n                ret = system_prompt + seps[0]\n            for i, (role, message) in enumerate(self.messages):\n                if message:\n                    ret += role + message + seps[i % 2]\n                else:\n                    ret += role\n            return ret\n        else:\n            raise ValueError(f\"Invalid style: {self.sep_style}\")\n\n    def set_system_message(self, system_message: str):\n        \"\"\"Set the system message.\"\"\"\n        self.system_message = system_message\n\n    def append_message(self, role: str, message: str):\n        \"\"\"Append a new message.\"\"\"\n        self.messages.append([role, message])\n\n    def append_image(self, image: str, detail: Literal[\"auto\", \"low\", \"high\"]):\n        \"\"\"Append a new image.\"\"\"\n        self.image_data.append(ImageData(url=image, detail=detail))\n\n    def append_video(self, video: str, preprocess_kwargs: Optional[Dict] = None):\n        \"\"\"Append a new video.\"\"\"\n        if preprocess_kwargs:\n            self.video_data.append(\n                VideoData(video, preprocess_kwargs=preprocess_kwargs)","sourceCodeStart":395,"sourceCodeEnd":431,"githubUrl":"https://github.com/sgl-project/sglang/blob/0132848349585cfe6aae51c4941cbae872505f8a/python/sglang/srt/parser/conversation.py#L395-L431","documentation":"SeparatorStyle.get_prompt() serializes a conversation according to self.sep_style, and only a fixed set of SeparatorStyle enum members have rendering branches. If a Conversation was constructed with an unrecognized or newly added SeparatorStyle value, the final else branch raises 'Invalid style'.","triggerScenarios":"Constructing a Conversation with sep_style set to a SeparatorStyle enum member (or raw int) that has no branch in get_prompt(), e.g. a style added to the enum but not implemented in get_prompt, or a custom/out-of-range integer passed as sep_style.","commonSituations":"Porting a new chat template into SGLang's conversation.py and registering the enum value without adding a rendering branch; deserializing a Conversation from stale config after an upgrade shifted enum values.","solutions":["Add a rendering branch in get_prompt() for the missing SeparatorStyle member","Verify the sep_style passed to the Conversation constructor is one of the styles handled in get_prompt()","Use an existing style (e.g. SeparatorStyle.PLAIN) instead of a custom value"],"exampleFix":"# before\nconv = Conversation(name=\"x\", sep_style=SeparatorStyle(99), ...)\n# after\nconv = Conversation(name=\"x\", sep_style=SeparatorStyle.PLAIN, ...)\n# or add to get_prompt():\n# elif self.sep_style == SeparatorStyle.MY_STYLE: ...","handlingStrategy":"validation","validationCode":"from sglang.srt.parser.conversation import SeparatorStyle\nassert conv.sep_style in SeparatorStyle, \"unknown sep_style\"  # plus ensure get_prompt handles it","typeGuard":null,"tryCatchPattern":null,"preventionTips":["When adding a SeparatorStyle enum member, add the get_prompt branch in the same commit","Add a unit test per style that calls get_prompt()"],"tags":["conversation","chat-template","parser"],"backgroundTag":"unsupported-enum-value","analyzedSha":"0132848349585cfe6aae51c4941cbae872505f8a","analyzedAt":"2026-08-28T05:10:05.995Z","schemaVersion":2},"datasetVersion":"2026-08-28T06:17:29.519Z"}