{"record":{"id":"69db2d8bc49f2fbb","repo":"vercel/ai","slug":"unsupported-file-mime-type-mimetype-expected","errorCode":null,"errorMessage":"Unsupported file mime type: ${mimeType}, expected one of: ${Object.keys(BEDROCK_DOCUMENT_MIME_TYPES).join(', ')}","messagePattern":"Unsupported file mime type: (.+?), expected one of: (.+?)","errorType":"exception","errorClass":"UnsupportedFunctionalityError","httpStatus":null,"severity":"error","filePath":"packages/amazon-bedrock/src/convert-to-amazon-bedrock-chat-messages.ts","lineNumber":672,"sourceCode":"  const format =\n    BEDROCK_IMAGE_MIME_TYPES[mimeType as AmazonBedrockImageMimeType];\n  if (!format) {\n    throw new UnsupportedFunctionalityError({\n      functionality: `image mime type: ${mimeType}`,\n      message: `Unsupported image mime type: ${mimeType}, expected one of: ${Object.keys(BEDROCK_IMAGE_MIME_TYPES).join(', ')}`,\n    });\n  }\n\n  return format;\n}\n\nfunction getAmazonBedrockDocumentFormat(\n  mimeType: string,\n): AmazonBedrockDocumentFormat {\n  const format =\n    BEDROCK_DOCUMENT_MIME_TYPES[mimeType as AmazonBedrockDocumentMimeType];\n  if (!format) {\n    throw new UnsupportedFunctionalityError({\n      functionality: `file mime type: ${mimeType}`,\n      message: `Unsupported file mime type: ${mimeType}, expected one of: ${Object.keys(BEDROCK_DOCUMENT_MIME_TYPES).join(', ')}`,\n    });\n  }\n  return format;\n}\n\nfunction getAmazonBedrockVideoFormat(\n  mimeType: string,\n): AmazonBedrockVideoFormat {\n  const format =\n    BEDROCK_VIDEO_MIME_TYPES[mimeType as AmazonBedrockVideoMimeType];\n  if (!format) {\n    throw new UnsupportedFunctionalityError({\n      functionality: `video mime type: ${mimeType}`,\n      message: `Unsupported video mime type: ${mimeType}, expected one of: ${Object.keys(BEDROCK_VIDEO_MIME_TYPES).join(', ')}`,\n    });\n  }","sourceCodeStart":654,"sourceCodeEnd":690,"githubUrl":"https://github.com/vercel/ai/blob/69428b1f8b037e4d118fb4853428d5c4e620493c/packages/amazon-bedrock/src/convert-to-amazon-bedrock-chat-messages.ts#L654-L690","documentation":"getAmazonBedrockDocumentFormat maps a document MIME type to a Bedrock document format and throws UnsupportedFunctionalityError when it is not in BEDROCK_DOCUMENT_MIME_TYPES. Bedrock documents support only pdf, csv, txt, and md (markdown).","triggerScenarios":"Passing a file/document part with a mediaType outside {application/pdf, text/csv, text/plain, text/markdown} — e.g. application/msword, application/vnd.openxmlformats-officedocument.wordprocessingml.document, or application/json.","commonSituations":"Sending Word/Excel/JSON files directly; these must be converted. Also occurs when a text part's media type is inferred as something unmapped, e.g. text/html.","solutions":["Convert documents to PDF before sending (e.g. libreoffice headless, puppeteer, or docx-to-pdf libraries).","For JSON/HTML content, extract the text and send it as a text/plain or text/markdown part.","Use one of the supported types listed in the error message.","Export spreadsheets to CSV instead of sending xlsx."],"exampleFix":"// before\n{ type: 'file', mediaType: 'application/vnd.openxmlformats-officedocument.wordprocessingml.document', data: docxBytes }\n// after\nconst pdf = await convertToPdf(docxBytes);\n{ type: 'file', mediaType: 'application/pdf', data: pdf, filename: 'report.pdf' }","handlingStrategy":"validation","validationCode":"const SUPPORTED_DOC = ['application/pdf','text/csv','text/plain','text/markdown'];\nif (!SUPPORTED_DOC.includes(filePart.mediaType)) {\n  throw new Error(`Convert ${filePart.mediaType} to PDF/CSV/TXT/MD before sending to Bedrock`);\n}","typeGuard":"function isBedrockSupportedDocument(mediaType) {\n  return ['application/pdf','text/csv','text/plain','text/markdown'].includes(mediaType);\n}","tryCatchPattern":"try {\n  return await generateText({ model, messages });\n} catch (error) {\n  if (UnsupportedFunctionalityError.isInstance(error) && error.message.includes('Unsupported file mime type')) {\n    console.error('Convert the document to PDF, CSV, TXT, or MD before sending to Bedrock.');\n  }\n  throw error;\n}","preventionTips":["Convert Office/JSON/HTML files to PDF or extracted text before model calls.","Validate file MIME types at upload time against Bedrock's allowlist.","Keep a document-conversion utility (e.g. LibreOffice headless) available in your pipeline."],"tags":["unsupported-functionality","bedrock","document","mime-type"],"backgroundTag":"unsupported-media-type","analyzedSha":"69428b1f8b037e4d118fb4853428d5c4e620493c","analyzedAt":"2026-08-30T12:32:21.016Z","schemaVersion":2},"datasetVersion":"2026-08-30T13:17:10.514Z"}