{"record":{"id":"437dde7c15bf84c9","repo":"sgl-project/sglang","slug":"invalid-message-for-role-role-msg","errorCode":null,"errorMessage":"Invalid message for role `{role}`: {msg}","messagePattern":"Invalid message for role `(.+?)`: (.+?)","errorType":"exception","errorClass":"DS32EncodingError","httpStatus":null,"severity":"error","filePath":"python/sglang/srt/entrypoints/openai/encoding_dsv32.py","lineNumber":198,"sourceCode":"\n    if tools:\n        tools = tools_from_openai_format(tools)\n    if tool_calls:\n        tool_calls = tool_calls_from_openai_format(tool_calls)\n\n    if role == \"system\":\n        prompt += system_msg_template.format(content=content or \"\")\n        if tools:\n            prompt += \"\\n\\n\" + render_tools(tools)\n\n        if response_format:\n            prompt += \"\\n\\n\" + response_format_template.format(\n                schema=to_json(response_format)\n            )\n\n    elif role == \"developer\":\n        if not content:\n            raise DS32EncodingError(f\"Invalid message for role `{role}`: {msg}\")\n        content_developer = \"\"\n        if tools:\n            content_developer += \"\\n\\n\" + render_tools(tools)\n\n        if response_format:\n            content_developer += \"\\n\\n\" + response_format_template.format(\n                schema=to_json(response_format)\n            )\n\n        content_developer += \"\\n\\n# The user's message is: {}\".format(content)\n\n        prompt += user_msg_template.format(content=content_developer)\n        if index == last_user_idx and thinking_mode == \"thinking\":\n            prompt += thinking_start_token\n        else:\n            prompt += thinking_end_token\n\n    elif role == \"user\":","sourceCodeStart":180,"sourceCodeEnd":216,"githubUrl":"https://github.com/sgl-project/sglang/blob/0132848349585cfe6aae51c4941cbae872505f8a/python/sglang/srt/entrypoints/openai/encoding_dsv32.py#L180-L216","documentation":"In the deepseek-v3.2 prompt encoding, a message with role 'developer' must have non-empty content. render_message raises DS32EncodingError when a developer message has empty/missing content (optionally after tools/response_format are appended).","triggerScenarios":"A messages array containing {'role':'developer','content':''} or content=None (with no tools/response_format to pad it), passed to the DSv32 serving/chat endpoint.","commonSituations":"Clients sending system-style developer prompts with empty strings; pipelines that strip content but keep the role; migrating system->developer roles after OpenAI API changes.","solutions":["Give the developer message non-empty content text.","If the message is intentionally empty, drop it from the messages list before sending.","Pass tools or response_format alongside if you expected them to fill the message."],"exampleFix":"# before\n{\"role\":\"developer\",\"content\":\"\"}\n# after\n{\"role\":\"developer\",\"content\":\"You are a helpful assistant.\"}","handlingStrategy":"validation","validationCode":"for m in messages:\n    if m['role']=='developer' and not m.get('content'):\n        raise ValueError('developer message needs content')","typeGuard":null,"tryCatchPattern":"try:\n    encode_messages(msgs)\nexcept DS32EncodingError as e:\n    # drop or fill empty developer messages, retry\n    ...","preventionTips":["Filter empty messages before sending.","Default developer content to a system prompt string."],"tags":["deepseek","developer-message","message-validation"],"backgroundTag":"request-message-validation","analyzedSha":"0132848349585cfe6aae51c4941cbae872505f8a","analyzedAt":"2026-08-28T05:10:05.995Z","schemaVersion":2},"datasetVersion":"2026-08-28T06:17:29.519Z"}