vercel/ai · error · UnsupportedFunctionalityError

Unsupported file mime type: ${mimeType}, expected one of: ${

Error message

Unsupported file mime type: ${mimeType}, expected one of: ${Object.keys(BEDROCK_DOCUMENT_MIME_TYPES).join(', ')}

What it means

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).

Source

Thrown at packages/amazon-bedrock/src/convert-to-amazon-bedrock-chat-messages.ts:672

  const format =
    BEDROCK_IMAGE_MIME_TYPES[mimeType as AmazonBedrockImageMimeType];
  if (!format) {
    throw new UnsupportedFunctionalityError({
      functionality: `image mime type: ${mimeType}`,
      message: `Unsupported image mime type: ${mimeType}, expected one of: ${Object.keys(BEDROCK_IMAGE_MIME_TYPES).join(', ')}`,
    });
  }

  return format;
}

function getAmazonBedrockDocumentFormat(
  mimeType: string,
): AmazonBedrockDocumentFormat {
  const format =
    BEDROCK_DOCUMENT_MIME_TYPES[mimeType as AmazonBedrockDocumentMimeType];
  if (!format) {
    throw new UnsupportedFunctionalityError({
      functionality: `file mime type: ${mimeType}`,
      message: `Unsupported file mime type: ${mimeType}, expected one of: ${Object.keys(BEDROCK_DOCUMENT_MIME_TYPES).join(', ')}`,
    });
  }
  return format;
}

function getAmazonBedrockVideoFormat(
  mimeType: string,
): AmazonBedrockVideoFormat {
  const format =
    BEDROCK_VIDEO_MIME_TYPES[mimeType as AmazonBedrockVideoMimeType];
  if (!format) {
    throw new UnsupportedFunctionalityError({
      functionality: `video mime type: ${mimeType}`,
      message: `Unsupported video mime type: ${mimeType}, expected one of: ${Object.keys(BEDROCK_VIDEO_MIME_TYPES).join(', ')}`,
    });
  }

View on GitHub (pinned to 69428b1f8b)

Solutions

  1. Convert documents to PDF before sending (e.g. libreoffice headless, puppeteer, or docx-to-pdf libraries).
  2. For JSON/HTML content, extract the text and send it as a text/plain or text/markdown part.
  3. Use one of the supported types listed in the error message.
  4. Export spreadsheets to CSV instead of sending xlsx.

Example fix

// before
{ type: 'file', mediaType: 'application/vnd.openxmlformats-officedocument.wordprocessingml.document', data: docxBytes }
// after
const pdf = await convertToPdf(docxBytes);
{ type: 'file', mediaType: 'application/pdf', data: pdf, filename: 'report.pdf' }
Defensive patterns

Strategy: validation

Validate before calling

const SUPPORTED_DOC = ['application/pdf','text/csv','text/plain','text/markdown'];
if (!SUPPORTED_DOC.includes(filePart.mediaType)) {
  throw new Error(`Convert ${filePart.mediaType} to PDF/CSV/TXT/MD before sending to Bedrock`);
}

Type guard

function isBedrockSupportedDocument(mediaType) {
  return ['application/pdf','text/csv','text/plain','text/markdown'].includes(mediaType);
}

Try / catch

try {
  return await generateText({ model, messages });
} catch (error) {
  if (UnsupportedFunctionalityError.isInstance(error) && error.message.includes('Unsupported file mime type')) {
    console.error('Convert the document to PDF, CSV, TXT, or MD before sending to Bedrock.');
  }
  throw error;
}

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Related errors


AI-assisted analysis of vercel/ai@69428b1f8b (2026-08-30). Data as JSON: /api/errors/69db2d8bc49f2fbb. Report an issue: GitHub.