{"record":{"id":"9954fbfa8f8b3bd5","repo":"sgl-project/sglang","slug":"unknown-role-role-9954fb","errorCode":null,"errorMessage":"Unknown role: {role}","messagePattern":"Unknown role: (.+?)","errorType":"validation","errorClass":"NotImplementedError","httpStatus":null,"severity":"error","filePath":"python/sglang/srt/entrypoints/openai/encoding_dsv4.py","lineNumber":438,"sourceCode":"                    thinking_template.format(reasoning_content=rc) + thinking_end_token\n                )\n            else:\n                thinking_part = \"\"\n\n        if wo_eos:\n            prompt += assistant_msg_wo_eos_template.format(\n                reasoning=thinking_part,\n                content=summary_content,\n                tool_calls=tc_content,\n            )\n        else:\n            prompt += assistant_msg_template.format(\n                reasoning=thinking_part,\n                content=summary_content,\n                tool_calls=tc_content,\n            )\n    else:\n        raise NotImplementedError(f\"Unknown role: {role}\")\n\n    # Append transition tokens based on what follows\n    if index + 1 < len(messages) and messages[index + 1].get(\"role\") not in [\n        \"assistant\",\n        \"latest_reminder\",\n    ]:\n        return prompt\n\n    task = messages[index].get(\"task\")\n    if task is not None:\n        # Task special token for internal classification tasks\n        assert (\n            task in VALID_TASKS\n        ), f\"Invalid task: '{task}'. Valid tasks are: {list(VALID_TASKS)}\"\n        task_sp_token = DS_TASK_SP_TOKENS[task]\n\n        if task != \"action\":\n            # Non-action tasks: append task sp token directly after the message","sourceCodeStart":420,"sourceCodeEnd":456,"githubUrl":"https://github.com/sgl-project/sglang/blob/0132848349585cfe6aae51c4941cbae872505f8a/python/sglang/srt/entrypoints/openai/encoding_dsv4.py#L420-L456","documentation":"DSv4 render_message reached the final else branch: the message role matched none of the supported roles (user/developer/assistant/latest_reminder/tool handled earlier).","triggerScenarios":"A message with an unrecognized role such as 'system' in DSv4 (if unsupported), 'function', or a typo like 'asistant'.","commonSituations":"Role typos; using legacy roles; roles supported by other templates but not DSv4.","solutions":["Check msg['role'] spelling and use a supported role.","Map legacy roles: 'system'->'developer', 'function'->tool handling via merge_tool_messages.","Log roles before sending to catch bad values early."],"exampleFix":"# before\n{\"role\":\"system\",\"content\":\"You are...\"}\n# after\n{\"role\":\"developer\",\"content\":\"You are...\"}","handlingStrategy":"type-guard","validationCode":"ALLOWED={'user','developer','assistant','latest_reminder'}\nassert all(m['role'] in ALLOWED for m in messages)","typeGuard":"def is_dsv4_role(r): return r in {'user','developer','assistant','latest_reminder'}","tryCatchPattern":null,"preventionTips":["Map system->developer for DSv4.","Check supported roles per encoder version."],"tags":["deepseek-v4","unknown-role","message-validation"],"backgroundTag":"unknown-message-role","analyzedSha":"0132848349585cfe6aae51c4941cbae872505f8a","analyzedAt":"2026-08-28T05:10:05.995Z","schemaVersion":2},"datasetVersion":"2026-08-28T06:17:29.519Z"}