{"record":{"id":"2f98b8eaf713a3d9","repo":"langchain-ai/langchain","slug":"block-of-type-block-type-is-not-supported","errorCode":null,"errorMessage":"Block of type {block['type']} is not supported.","messagePattern":"Block of type (.+?) is not supported\\.","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"libs/core/langchain_core/messages/block_translators/openai.py","lineNumber":151,"sourceCode":"            error_msg = \"Keys base64, url, or file_id required for file blocks.\"\n            raise ValueError(error_msg)\n\n    elif block[\"type\"] == \"audio\":\n        if \"base64\" in block or block.get(\"source_type\") == \"base64\":\n            # Handle v0 format: {\"source_type\": \"base64\", \"data\": \"...\", ...}\n            # Handle v1 format: {\"base64\": \"...\", ...}\n            base64_data = block[\"data\"] if \"source_type\" in block else block[\"base64\"]\n            audio_format = block[\"mime_type\"].split(\"/\")[-1]\n            formatted_block = {\n                \"type\": \"input_audio\",\n                \"input_audio\": {\"data\": base64_data, \"format\": audio_format},\n            }\n        else:\n            error_msg = \"Key base64 is required for audio blocks.\"\n            raise ValueError(error_msg)\n    else:\n        error_msg = f\"Block of type {block['type']} is not supported.\"\n        raise ValueError(error_msg)\n\n    return formatted_block\n\n\n# v1 / Chat Completions\ndef _convert_to_v1_from_chat_completions(\n    message: AIMessage,\n) -> list[types.ContentBlock]:\n    \"\"\"Mutate a Chat Completions message to v1 format.\"\"\"\n    content_blocks: list[types.ContentBlock] = []\n    if isinstance(message.content, str):\n        if message.content:\n            content_blocks = [{\"type\": \"text\", \"text\": message.content}]\n        else:\n            content_blocks = []\n\n    for tool_call in message.tool_calls:\n        content_blocks.append(","sourceCodeStart":133,"sourceCodeEnd":169,"githubUrl":"https://github.com/langchain-ai/langchain/blob/e32fa9a52eab3b61ad7a45399bfde59b3e580fc4/libs/core/langchain_core/messages/block_translators/openai.py#L133-L169","documentation":"Raised when `convert_to_openai_data_block` (or a model path using it) receives a content block whose `type` is not one of the supported kinds (image, file, audio on the data-block path). It is a catch-all guard so unsupported block types fail loudly before a malformed request reaches OpenAI.","triggerScenarios":"Passing blocks like `{\"type\": \"text\", ...}`, `{\"type\": \"reasoning\", ...}`, `{\"type\": \"tool_call\", ...}` or a custom/typo'd type into the data-block converter; forwarding a full v1 content list where non-multimedia blocks were not filtered out first.","commonSituations":"Iterating over all content blocks of a message and sending each through the multimodal formatter without filtering; new block types added in newer langchain-core versions flowing into older conversion code; typos such as `\"type\": \"imag\"`.","solutions":["Filter blocks before conversion: only pass `image`, `file`, and `audio` blocks to this converter","Route `text` blocks to the string/text path and tool/reasoning blocks to their own handlers","Check for typos in the `type` field of hand-built blocks"],"exampleFix":"# before\nfor block in message.content:\n    openai_blocks.append(convert_to_openai_data_block(block))  # crashes on text blocks\n\n# after\nfor block in message.content:\n    if block.get(\"type\") in {\"image\", \"file\", \"audio\"}:\n        openai_blocks.append(convert_to_openai_data_block(block))","handlingStrategy":"type-guard","validationCode":"SUPPORTED_DATA_BLOCKS = {\"image\", \"file\", \"audio\"}\n\ndef is_supported_data_block(block: dict) -> bool:\n    return block.get(\"type\") in SUPPORTED_DATA_BLOCKS","typeGuard":"def is_supported_data_block(block: dict) -> bool:\n    return block.get(\"type\") in {\"image\", \"file\", \"audio\"}","tryCatchPattern":null,"preventionTips":["Filter content lists by type before calling multimodal converters","Handle text blocks on the text path, not the data-block path","Pin the block-type allowlist in one constant and reuse it"],"tags":["openai","content-blocks","type-dispatch","validation"],"backgroundTag":null,"analyzedSha":"e32fa9a52eab3b61ad7a45399bfde59b3e580fc4","analyzedAt":"2026-08-14T18:42:09.092Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}