{"record":{"id":"2c87024b46b1cf89","repo":"mastra-ai/mastra","slug":"unknown-content-type-content-as-any-type","errorCode":null,"errorMessage":"Unknown content type: ${(content as any).type}","messagePattern":"Unknown content type: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"embedders/voyageai/src/multimodal-embedding.ts","lineNumber":33,"sourceCode":"  VoyageInputType,\n} from './types';\n\n/**\n * Convert our content format to the VoyageAI SDK's content-item shape.\n * The API requires typed objects (never bare strings) inside each input's `content` array.\n */\nfunction toSdkContent(content: VoyageMultimodalContent): Record<string, unknown> {\n  switch (content.type) {\n    case 'text':\n      return { type: 'text', text: content.text };\n    case 'image_url':\n      return { type: 'image_url', image_url: content.image_url };\n    case 'image_base64':\n      return { type: 'image_base64', image_base64: content.image_base64 };\n    case 'video_url':\n      return { type: 'video_url', video_url: content.video_url };\n    default:\n      throw new Error(`Unknown content type: ${(content as any).type}`);\n  }\n}\n\n/**\n * Convert a multimodal input to the SDK's input-item shape: an object with a\n * `content` array of typed content objects.\n */\nfunction toSdkInput(input: VoyageMultimodalInput): { content: Record<string, unknown>[] } {\n  return { content: input.content.map(toSdkContent) };\n}\n\n/**\n * Convert our input type to VoyageAI SDK's expected format\n */\nfunction toSdkInputType(inputType: VoyageInputType | undefined): 'query' | 'document' | undefined {\n  if (inputType === null) return undefined;\n  return inputType;\n}","sourceCodeStart":15,"sourceCodeEnd":51,"githubUrl":"https://github.com/mastra-ai/mastra/blob/75dd419e613fe9c39f846ffc500716141b74fda6/embedders/voyageai/src/multimodal-embedding.ts#L15-L51","documentation":"toSdkContent maps Mastra multimodal content items to the Voyage SDK shape and supports text, image_url, image_base64, and video_url. Any other content .type hits the default branch and throws, because the Voyage multimodal API has no encoding for it.","triggerScenarios":"Passing a multimodal input containing a content item with an unsupported type value (e.g. 'audio_url', 'file', a mistyped 'ImageUrl', or an undefined type from a malformed message).","commonSituations":"Building multimodal messages from generic AI SDK content (which includes audio/file types Voyage doesn't accept), misspelling a type literal, or passing untyped objects where type is undefined.","solutions":["Convert unsupported content types (e.g. audio) to a supported form or remove them from the input.","Check each item's type is exactly one of 'text' | 'image_url' | 'image_base64' | 'video_url' before calling.","Ensure message objects are constructed with the library's content types, not raw external formats."],"exampleFix":"// before\n{ type: 'audio_url', audio_url: { url: 'https://...' } }\n// after\n{ type: 'video_url', video_url: { url: 'https://...' } } // or a supported type","handlingStrategy":"type-guard","validationCode":"const SUPPORTED = new Set(['text', 'image_url', 'image_base64', 'video_url']);\nfor (const item of input) {\n  for (const c of item.content) {\n    if (!SUPPORTED.has((c as any).type)) {\n      throw new Error(`Unsupported Voyage content type: ${(c as any).type}`);\n    }\n  }\n}","typeGuard":"type VoyageContent = { type: 'text' } | { type: 'image_url'; image_url: unknown } | { type: 'image_base64'; image_base64: unknown } | { type: 'video_url'; video_url: unknown };\nfunction isVoyageContent(c: unknown): c is VoyageContent {\n  const t = (c as any)?.type;\n  return t === 'text' || t === 'image_url' || t === 'image_base64' || t === 'video_url';\n}","tryCatchPattern":"try {\n  await embedder.embed(input);\n} catch (err) {\n  if ((err as Error).message.startsWith('Unknown content type:')) {\n    console.error('Strip or convert the unsupported item before embedding');\n  }\n  throw err;\n}","preventionTips":["Pre-filter multimodal messages to Voyage-supported types before calling.","Convert audio/file content to text descriptions or supported media.","Type message content with the library's content unions to catch mistakes at compile time.","Log the offending item's type when it fails for fast diagnosis."],"tags":["voyageai","multimodal","unsupported-type","input-validation"],"backgroundTag":"unsupported-content-type","analyzedSha":"75dd419e613fe9c39f846ffc500716141b74fda6","analyzedAt":"2026-08-30T00:15:31.844Z","schemaVersion":2},"datasetVersion":"2026-08-30T03:17:51.788Z"}