{"record":{"id":"a078d51bde300798","repo":"sgl-project/sglang","slug":"content-part-must-be-mapping-got-type-part-na","errorCode":null,"errorMessage":"content part must be mapping, got {type(part).__name__}","messagePattern":"content part must be mapping, got (.+?)","errorType":"validation","errorClass":"TypeError","httpStatus":null,"severity":"error","filePath":"python/sglang/srt/parser/inkling_renderer.py","lineNumber":230,"sourceCode":"    input_ids.append(tokenizer.encode_special(END_MESSAGE))\n\n\ndef _iter_render_parts(content: Any):\n    \"\"\"Yield ordered ``(kind, text)`` pairs from message content.\"\"\"\n    if content is None:\n        return\n    if isinstance(content, str):\n        if content:\n            yield (\"text\", content)\n        return\n    if not isinstance(content, Sequence) or isinstance(content, (bytes, bytearray)):\n        raise TypeError(\"message content must be a string or a sequence of parts\")\n    for part in content:\n        if isinstance(part, str):\n            yield (\"text\", part)\n            continue\n        if not isinstance(part, Mapping):\n            raise TypeError(f\"content part must be mapping, got {type(part).__name__}\")\n        ptype = part.get(\"type\")\n        if ptype in (None, \"text\", \"input_text\"):\n            text = part.get(\"text\", \"\")\n            yield (\"text\", text if isinstance(text, str) else \"\")\n        elif ptype in (\"thinking\", \"reasoning\"):\n            text = part.get(\"thinking\")\n            if text is None:\n                text = part.get(\"text\", \"\")\n            if not isinstance(text, str):\n                raise TypeError(\"Inkling thinking part payload must be a string\")\n            yield (\"thinking\", text)\n        elif ptype in _IMAGE_PART_TYPES:\n            yield (\"image\", \"\")\n        elif ptype in _AUDIO_PART_TYPES:\n            yield (\"audio\", \"\")\n        else:\n            raise ValueError(f\"unsupported content part type: {ptype!r}\")\n","sourceCodeStart":212,"sourceCodeEnd":248,"githubUrl":"https://github.com/sgl-project/sglang/blob/0132848349585cfe6aae51c4941cbae872505f8a/python/sglang/srt/parser/inkling_renderer.py#L212-L248","documentation":"When content is a sequence, every element must be either a string or a Mapping (part dict). A non-mapping element such as an int, list, or tuple raises TypeError naming the actual type.","triggerScenarios":"content=[\"ok\", 42] or content=[[\"nested\"]] — a list element that is neither str nor dict.","commonSituations":"Clients that build content lists programmatically and accidentally include raw values or nested lists.","solutions":["Convert every element to a part dict {\"type\":\"text\",\"text\":str(value)} or a plain string","Flatten nested lists before sending"],"exampleFix":"# before\ncontent=[\"hi\", 42]\n# after\ncontent=[\"hi\", {\"type\":\"text\",\"text\":\"42\"}]","handlingStrategy":"type-guard","validationCode":"for m in messages:\n    c = m.get(\"content\", \"\")\n    if isinstance(c, list):\n        assert all(isinstance(p, (str, dict)) for p in c), [type(p).__name__ for p in c]","typeGuard":"def parts_ok(c):\n    return not isinstance(c, list) or all(isinstance(p, (str, dict)) for p in c)","tryCatchPattern":null,"preventionTips":["Build content lists from typed helpers that only emit str or part dicts","Flatten nested structures client-side"],"tags":["inkling","type-error","content-parts"],"backgroundTag":"invalid-field-type","analyzedSha":"0132848349585cfe6aae51c4941cbae872505f8a","analyzedAt":"2026-08-28T05:10:05.995Z","schemaVersion":2},"datasetVersion":"2026-08-28T06:17:29.519Z"}