{"record":{"id":"d36efb0dd55a759c","repo":"mlflow/mlflow","slug":"unknown-content-type-content-type-type-plea","errorCode":null,"errorMessage":"Unknown content type: {content_type['type']}. Please make sure the message is a valid Anthropic message object. If it is a valid type, contact to the MLflow maintainer via https://github.com/mlflow/mlflow/issues/new/choose for requesting support for a new message type.","messagePattern":"Unknown content type: (.+?)\\. Please make sure the message is a valid Anthropic message object\\. If it is a valid type, contact to the MLflow maintainer via https://github\\.com/mlflow/mlflow/issues/new/choose for requesting support for a new message type\\.","errorType":"validation","errorClass":"MlflowException","httpStatus":null,"severity":"error","filePath":"mlflow/anthropic/chat.py","lineNumber":110,"sourceCode":"\n    content_type = content.get(\"type\")\n    if content_type == \"text\":\n        return TextContentPart(text=content[\"text\"], type=\"text\")\n    elif content_type == \"image\":\n        source = content[\"source\"]\n        return ImageContentPart(\n            image_url=ImageUrl(\n                url=f\"data:{source['media_type']};{source['type']},{source['data']}\"\n            ),\n            type=\"image_url\",\n        )\n    # Claude 3.7 added new \"thinking\" content block, which is essentially a text block as of now.\n    # TODO: We should consider adding a new ContentPart type if more providers support this.\n    # https://docs.anthropic.com/en/docs/build-with-claude/extended-thinking\n    elif content_type == \"thinking\":\n        return TextContentPart(text=content[\"thinking\"], type=\"text\")\n    else:\n        raise MlflowException.invalid_parameter_value(\n            f\"Unknown content type: {content_type['type']}. Please make sure the message \"\n            \"is a valid Anthropic message object. If it is a valid type, contact to the \"\n            \"MLflow maintainer via https://github.com/mlflow/mlflow/issues/new/choose for \"\n            \"requesting support for a new message type.\"\n        )\n\n\ndef convert_tool_to_mlflow_chat_tool(tool: dict[str, Any]) -> ChatTool:\n    \"\"\"\n    Convert Anthropic tool definition into MLflow's standard format (OpenAI compatible).\n\n    Ref: https://docs.anthropic.com/en/docs/build-with-claude/tool-use\n\n    Args:\n        tool: A dictionary represents a single tool definition in the input request.\n\n    Returns:\n        ChatTool: MLflow's standard tool definition object.","sourceCodeStart":92,"sourceCodeEnd":128,"githubUrl":"https://github.com/mlflow/mlflow/blob/6a27f2decc0b76eb1b54af31849784addb357dbc/mlflow/anthropic/chat.py#L92-L128","documentation":"Within a list content, each block's 'type' must be one MLflow knows: text, image, tool_use, tool_result, or thinking (Claude 3.7 extended thinking, mapped to text). An unrecognized block type cannot be converted to a ContentPart, so MLflow raises this error and asks you to file an issue if the type is genuinely valid Anthropic content.","triggerScenarios":"A content block with 'type' like 'document', 'server_tool_use', 'web_search_tool_result', 'redacted_thinking', or any new Anthropic block type not yet handled by your MLflow version; passing through _parse_content with a dict lacking/misspelling 'type' (content_type becomes None).","commonSituations":"Using new Anthropic API features (documents/PDFs, web search, code execution blocks) with an older MLflow; a typo in the 'type' field; 'type' key missing entirely so None is reported.","solutions":["Upgrade MLflow to the latest version, which may support the new block type","Strip or pre-convert unsupported blocks to {'type': 'text', 'text': ...} before logging","If the type is valid Anthropic content, file an issue at https://github.com/mlflow/mlflow/issues/new/choose","Verify each block dict has a correctly spelled 'type' key"],"exampleFix":"// before\nblocks = [{\"type\": \"document\", \"source\": {...}}]\n// after\nblocks = [{\"type\": \"text\", \"text\": extract_text_from_document()}]  # or upgrade mlflow","handlingStrategy":"try-catch","validationCode":"KNOWN = {\"text\", \"image\", \"tool_use\", \"tool_result\", \"thinking\"}\nunsupported = [b[\"type\"] for m in messages if isinstance(m.get(\"content\"), list)\n               for b in m[\"content\"] if isinstance(b, dict) and b.get(\"type\") not in KNOWN]\nassert not unsupported, f\"Unsupported block types: {unsupported}\"","typeGuard":"def is_supported_block(b: dict) -> bool:\n    return isinstance(b, dict) and b.get(\"type\") in {\"text\", \"image\", \"tool_use\", \"tool_result\", \"thinking\"}","tryCatchPattern":"try:\n    trace = model_to_chat(response)\nexcept MlflowException as e:\n    if \"Unknown content type\" in str(e):\n        response.content = [b for b in response.content if getattr(b, \"type\", None) in {\"text\", \"tool_use\", \"thinking\"}]\n        trace = model_to_chat(response)\n    else:\n        raise","preventionTips":["Keep MLflow updated when adopting new Anthropic features (documents, web search)","Filter or flatten unsupported blocks before logging traces","Check mlflow release notes for new Anthropic content-type support"],"tags":["anthropic","content-block","unsupported-type","version-compatibility"],"backgroundTag":"unsupported-content-type","analyzedSha":"6a27f2decc0b76eb1b54af31849784addb357dbc","analyzedAt":"2026-08-29T20:54:51.419Z","schemaVersion":2},"datasetVersion":"2026-08-29T22:17:34.462Z"}