{"record":{"id":"3c3061697c041510","repo":"vercel/ai","slug":"ai-unsupportedfunctionalityerror-3c3061","errorCode":"AI_UnsupportedFunctionalityError","errorMessage":"'file part data type ${part.data.type}' functionality not supported.","messagePattern":"'file part data type (.+?)' functionality not supported\\.","errorType":"exception","errorClass":"UnsupportedFunctionalityError","httpStatus":null,"severity":"error","filePath":"packages/alibaba/src/convert-to-alibaba-chat-messages.ts","lineNumber":23,"sourceCode":"} from '@ai-sdk/provider';\nimport {\n  convertToBase64,\n  getTopLevelMediaType,\n  resolveFullMediaType,\n} from '@ai-sdk/provider-utils';\nimport type { AlibabaChatPrompt } from './alibaba-chat-prompt';\nimport type { CacheControlValidator } from './get-cache-control';\n\nfunction formatImageUrl({ part }: { part: LanguageModelV4FilePart }): string {\n  if (part.data.type === 'url') {\n    return part.data.url.toString();\n  }\n\n  if (part.data.type === 'data') {\n    return `data:${resolveFullMediaType({ part })};base64,${convertToBase64(part.data.data)}`;\n  }\n\n  throw new UnsupportedFunctionalityError({\n    functionality: `file part data type ${part.data.type}`,\n  });\n}\n\nexport function convertToAlibabaChatMessages({\n  prompt,\n  cacheControlValidator,\n}: {\n  prompt: LanguageModelV4Prompt;\n  cacheControlValidator?: CacheControlValidator;\n}): AlibabaChatPrompt {\n  const messages: AlibabaChatPrompt = [];\n\n  for (const { role, content, ...message } of prompt) {\n    const messageCacheControl = cacheControlValidator?.getCacheControl(\n      message.providerOptions,\n    );\n","sourceCodeStart":5,"sourceCodeEnd":41,"githubUrl":"https://github.com/vercel/ai/blob/69428b1f8b037e4d118fb4853428d5c4e620493c/packages/alibaba/src/convert-to-alibaba-chat-messages.ts#L5-L41","documentation":"formatImageUrl converts AI SDK file parts into data URLs for Alibaba messages. Only 'url' and 'data' (binary) part types are convertible; any other part.data.type (e.g. a new or provider-specific kind) reaches the final throw of UnsupportedFunctionalityError.","triggerScenarios":"Passing a message file part whose data.type is neither 'url' nor 'data' — e.g. { type: 'reference' } routed through formatImageUrl or a future/unknown part kind — while converting the prompt for Alibaba chat.","commonSituations":"Forwarding provider-specific file references (e.g. from another provider's response) into an Alibaba request, or SDK version skew introducing new file part data types.","solutions":["Send file parts with { type: 'url' } or raw binary { type: 'data' } (Uint8Array) instead","Strip or convert reference-type parts before the call","Update @ai-sdk/alibaba in case a newer core introduced the new part type"],"exampleFix":"// before\ncontent: [{ type: 'file', data: { type: 'reference', reference: fileRef }, mediaType: 'image/png' }]\n// after\ncontent: [{ type: 'file', data: { type: 'url', url: 'https://.../img.png' }, mediaType: 'image/png' }]","handlingStrategy":"validation","validationCode":"prompt.forEach(m => m.content.forEach(p => {\n  if (p.type === 'file' && p.data.type !== 'url' && p.data.type !== 'data') throw new Error('Unsupported file part data type');\n}));","typeGuard":"function isConvertibleFilePart(p: any): boolean {\n  return p?.type === 'file' && (p.data?.type === 'url' || p.data?.type === 'data');\n}","tryCatchPattern":"try {\n  await streamText({ model: alibabaModel, messages });\n} catch (e) {\n  if (UnsupportedFunctionalityError.isInstance(e) && e.functionality.startsWith('file part data type')) {\n    // rebuild messages with url/data file parts\n  }\n}","preventionTips":["Normalize file parts to url or data types in cross-provider pipelines","Strip provider-specific references before sending to Alibaba","Add prompt sanitization when routing shared conversation state across providers"],"tags":["file-parts","unsupported-functionality","content-conversion"],"backgroundTag":"unsupported-file-part-type","analyzedSha":"69428b1f8b037e4d118fb4853428d5c4e620493c","analyzedAt":"2026-08-30T12:32:21.016Z","schemaVersion":2},"datasetVersion":"2026-08-30T13:17:10.514Z"}