{"record":{"id":"e98932205df297cc","repo":"BerriAI/litellm","slug":"unsupported-content-type-type-content","errorCode":null,"errorMessage":"Unsupported content type: {type(content)}","messagePattern":"Unsupported content type: (.+?)","errorType":"exception","errorClass":"Exception","httpStatus":null,"severity":"error","filePath":"litellm/llms/databricks/chat/transformation.py","lineNumber":483,"sourceCode":"        return cast(AllMessageValues, transformed_message)\n\n    @staticmethod\n    def extract_content_str(\n        content: AllDatabricksContentValues | None,\n    ) -> str | None:\n        if content is None:\n            return None\n        if isinstance(content, str):\n            return content\n        elif isinstance(content, list):\n            content_str = \"\"\n            for item in content:\n                if item.get(\"type\") == \"text\":\n                    text_value = item.get(\"text\", \"\")\n                    content_str += str(text_value) if text_value is not None else \"\"\n            return content_str\n        else:\n            raise Exception(f\"Unsupported content type: {type(content)}\")\n\n    @staticmethod\n    def extract_reasoning_content(\n        content: AllDatabricksContentValues | None,\n    ) -> tuple[\n        str | None,\n        list[ChatCompletionThinkingBlock | ChatCompletionRedactedThinkingBlock] | None,\n    ]:\n        \"\"\"\n        Extract and return the reasoning content and thinking blocks\n        \"\"\"\n        if content is None:\n            return None, None\n        thinking_blocks: list[ChatCompletionThinkingBlock | ChatCompletionRedactedThinkingBlock] | None = None\n        reasoning_content: str | None = None\n        if isinstance(content, list):\n            for item in content:\n                if item.get(\"type\") == \"reasoning\":","sourceCodeStart":465,"sourceCodeEnd":501,"githubUrl":"https://github.com/BerriAI/litellm/blob/6c2dcb801bf2b75c18f1bb24140e7cf57465cc4d/litellm/llms/databricks/chat/transformation.py#L465-L501","documentation":"Raised by the Databricks chat transformer when a message's 'content' is neither None, a string, nor a list — the only content shapes it knows how to convert to text. The exception message includes the offending Python type. This happens during request/response content normalization, typically for assistant/tool message content in non-streaming transformations.","triggerScenarios":"Passing messages whose content is an int, float, dict, or any non-str/non-list object, e.g. messages=[{\"role\": \"user\", \"content\": 42}] or a dict content block that is not a list of typed parts.","commonSituations":"Building messages dynamically from unvalidated user data; content set to a number from a template variable; a dict intended for the OpenAI content-parts API passed directly instead of being wrapped in a list.","solutions":["Coerce content to str before calling: str(value) for scalar values","Wrap single content part dicts in a list: [{\"type\": \"text\", \"text\": ...}]","Validate/sanitize your message array with a helper before sending to litellm"],"exampleFix":"# before\nmessages = [{\"role\": \"user\", \"content\": user_id}]  # int\n\n# after\nmessages = [{\"role\": \"user\", \"content\": str(user_id)}]","handlingStrategy":"type-guard","validationCode":"def normalize_messages(messages):\n    for m in messages:\n        c = m.get(\"content\")\n        if c is not None and not isinstance(c, (str, list)):\n            m[\"content\"] = str(c)\n    return messages","typeGuard":"def has_valid_content(messages: list[dict]) -> bool:\n    return all(\n        m.get(\"content\") is None or isinstance(m.get(\"content\"), (str, list))\n        for m in messages\n    )","tryCatchPattern":"try:\n    resp = litellm.completion(model=m, messages=messages)\nexcept Exception as e:\n    if \"Unsupported content type\" in str(e):\n        messages = normalize_messages(messages)\n        resp = litellm.completion(model=m, messages=messages)\n    else:\n        raise","preventionTips":["Sanitize message content at your API boundary: coerce non-string scalars with str()","Wrap single dict content parts in a list before sending"],"tags":["databricks","chat","validation","request"],"backgroundTag":null,"analyzedSha":"6c2dcb801bf2b75c18f1bb24140e7cf57465cc4d","analyzedAt":"2026-08-15T07:12:03.035Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}