{"record":{"id":"23c4ef19d3701d3b","repo":"sgl-project/sglang","slug":"unknown-role-role","errorCode":null,"errorMessage":"Unknown role: {role}","messagePattern":"Unknown role: (.+?)","errorType":"exception","errorClass":"NotImplementedError","httpStatus":null,"severity":"error","filePath":"python/sglang/srt/entrypoints/openai/encoding_dsv32.py","lineNumber":291,"sourceCode":"        summary_content = content or \"\"\n\n        if thinking_mode == \"thinking\" and index > last_user_idx:\n            if not (reasoning_content or tool_calls):\n                raise DS32EncodingError(\n                    f\"ThinkingMode: {thinking_mode}, invalid message without reasoning_content/tool_calls `{msg}` after last user message\"\n                )\n            thinking_part = (\n                thinking_template.format(reasoning_content=reasoning_content or \"\")\n                + thinking_end_token\n            )\n\n        prompt += assistant_msg_template.format(\n            reasoning=thinking_part,\n            content=summary_content,\n            tool_calls=tool_calls_content,\n        )\n    else:\n        raise NotImplementedError(f\"Unknown role: {role}\")\n\n    return prompt\n\n\ndef drop_thinking_messages(\n    messages: List[Dict[str, Any]], last_user_idx: Optional[int] = None\n) -> List[Dict[str, Any]]:\n    messages_wo_thinking: List[Dict[str, Any]] = []\n    last_user_idx = (\n        find_last_user_index(messages) if last_user_idx is None else last_user_idx\n    )\n    for idx, msg in enumerate(messages):\n        role = msg.get(\"role\")\n        if role in [\"user\", \"system\", \"tool\"] or idx >= last_user_idx:\n            messages_wo_thinking.append(msg)\n            continue\n\n        elif role == \"assistant\":","sourceCodeStart":273,"sourceCodeEnd":309,"githubUrl":"https://github.com/sgl-project/sglang/blob/0132848349585cfe6aae51c4941cbae872505f8a/python/sglang/srt/entrypoints/openai/encoding_dsv32.py#L273-L309","documentation":"render_message hit a message role it cannot handle. DSv32 supports a fixed set (user/system/developer/tool/assistant); anything else raises NotImplementedError.","triggerScenarios":"A message with role like 'function', 'latest_reminder', or a typo ('assistent') in the messages array.","commonSituations":"Porting OpenAI 'function' call transcripts; typos in role strings; new role names not supported by this encoder version.","solutions":["Fix the role string to one of the supported roles.","Convert legacy 'function' role messages to 'tool' with tool_call_id.","Upgrade sglang if the role is newly supported."],"exampleFix":"# before\n{\"role\":\"function\",\"content\":\"42\"}\n# after\n{\"role\":\"tool\",\"tool_call_id\":\"1\",\"content\":\"42\"}","handlingStrategy":"type-guard","validationCode":"ALLOWED={'user','system','developer','assistant','tool'}\nassert all(m['role'] in ALLOWED for m in messages)","typeGuard":"def is_known_role(r): return r in {'user','system','developer','assistant','tool'}","tryCatchPattern":null,"preventionTips":["Validate roles client-side against a constant set.","Map legacy 'function' role to 'tool'."],"tags":["deepseek","unknown-role","chat-template"],"backgroundTag":"unknown-message-role","analyzedSha":"0132848349585cfe6aae51c4941cbae872505f8a","analyzedAt":"2026-08-28T05:10:05.995Z","schemaVersion":2},"datasetVersion":"2026-08-28T06:17:29.519Z"}