{"record":{"id":"a72d75672e8a8f69","repo":"sgl-project/sglang","slug":"the-system-message-should-be-a-single-text","errorCode":null,"errorMessage":"The system message should be a single text.","messagePattern":"The system message should be a single text\\.","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"python/sglang/srt/parser/conversation.py","lineNumber":640,"sourceCode":"        image_token=conv.image_token,\n        audio_token=conv.audio_token,\n        video_token=conv.video_token,\n        image_token_at_prefix=conv.image_token_at_prefix,\n    )\n\n    if isinstance(request.messages, str):\n        raise ValueError(\"The messages should be a list of dict.\")\n    for message in request.messages:\n        msg_role = message.role\n        if msg_role == \"system\":\n            if isinstance(message.content, str):\n                conv.system_message = message.content\n            elif isinstance(message.content, list):\n                if (\n                    len(message.content) != 1\n                    or getattr(message.content[0], \"type\", None) != \"text\"\n                ):\n                    raise ValueError(\"The system message should be a single text.\")\n                else:\n                    conv.system_message = getattr(message.content[0], \"text\", \"\")\n        elif msg_role == \"user\":\n            # Handle the various types of Chat Request content types here.\n            if isinstance(message.content, str):\n                conv.append_message(conv.roles[0], message.content)\n            else:\n                real_content = \"\"\n                # calculate number of image_url\n                num_image_url = 0\n                for content in message.content:\n                    if content.type == \"image_url\":\n                        num_image_url += 1\n                        conv.modalities.append(content.modalities)\n                image_token = (\n                    conv.image_token + \"\\n\"\n                    if conv.name not in (\"qwen2-vl\", \"moss-vl\", \"unlimited-ocr\")\n                    else conv.image_token","sourceCodeStart":622,"sourceCodeEnd":658,"githubUrl":"https://github.com/sgl-project/sglang/blob/0132848349585cfe6aae51c4941cbae872505f8a/python/sglang/srt/parser/conversation.py#L622-L658","documentation":"A system message whose content is a list must contain exactly one part of type 'text'. If the list is empty, has more than one element, or its first element's type is not 'text' (e.g. 'image_url'), generate_chat_conv raises this ValueError.","triggerScenarios":"Sending messages=[{\"role\":\"system\",\"content\":[{\"type\":\"image_url\",...}]}, ...] or a system message with content=[{\"type\":\"text\",...},{\"type\":\"text\",...}] (two parts).","commonSituations":"Copying multimodal user-message formatting into the system role; frontends that always wrap content in a parts list.","solutions":["Make the system message content a plain string: \"content\": \"You are helpful\"","If using a list, keep exactly one part with \"type\":\"text\"","Move images to a user message — system role cannot carry multimodal content"],"exampleFix":"# before\n{\"role\":\"system\",\"content\":[{\"type\":\"text\",\"text\":\"a\"},{\"type\":\"text\",\"text\":\"b\"}]}\n# after\n{\"role\":\"system\",\"content\":\"You are helpful\"}","handlingStrategy":"type-guard","validationCode":"for m in messages:\n    if m[\"role\"] == \"system\" and isinstance(m[\"content\"], list):\n        assert len(m[\"content\"]) == 1 and m[\"content\"][0].get(\"type\") == \"text\"","typeGuard":"def ok_system(c): return isinstance(c, str) or (isinstance(c, list) and len(c)==1 and isinstance(c[0], dict) and c[0].get(\"type\")==\"text\")","tryCatchPattern":null,"preventionTips":["Prefer plain-string system messages","Never attach images to the system role"],"tags":["chat-api","system-message","validation"],"backgroundTag":"invalid-request-payload","analyzedSha":"0132848349585cfe6aae51c4941cbae872505f8a","analyzedAt":"2026-08-28T05:10:05.995Z","schemaVersion":2},"datasetVersion":"2026-08-28T06:17:29.519Z"}