{"record":{"id":"317f58fd7c914ed9","repo":"vercel/ai","slug":"text-file-parts","errorCode":null,"errorMessage":"text file parts","messagePattern":"text file parts","errorType":"exception","errorClass":"UnsupportedFunctionalityError","httpStatus":null,"severity":"error","filePath":"packages/mistral/src/convert-to-mistral-chat-messages.ts","lineNumber":62,"sourceCode":"\n      case 'user': {\n        messages.push({\n          role: 'user',\n          content: content.map(part => {\n            switch (part.type) {\n              case 'text': {\n                return { type: 'text', text: part.text };\n              }\n\n              case 'file': {\n                switch (part.data.type) {\n                  case 'reference': {\n                    throw new UnsupportedFunctionalityError({\n                      functionality: 'file parts with provider references',\n                    });\n                  }\n                  case 'text': {\n                    throw new UnsupportedFunctionalityError({\n                      functionality: 'text file parts',\n                    });\n                  }\n                  case 'url':\n                  case 'data': {\n                    const topLevel = getTopLevelMediaType(part.mediaType);\n\n                    if (topLevel === 'image') {\n                      return {\n                        type: 'image_url',\n                        image_url: formatFileUrl({ part }),\n                      };\n                    } else {\n                      if (part.data.type === 'data') {\n                        const fullMediaType = resolveFullMediaType({ part });\n                        if (fullMediaType !== 'application/pdf') {\n                          throw new UnsupportedFunctionalityError({\n                            functionality:","sourceCodeStart":44,"sourceCodeEnd":80,"githubUrl":"https://github.com/vercel/ai/blob/69428b1f8b037e4d118fb4853428d5c4e620493c/packages/mistral/src/convert-to-mistral-chat-messages.ts#L44-L80","documentation":"Mistral chat models don't accept file parts whose content is inline text (data.type === 'text'). convertToMistralChatMessages throws UnsupportedFunctionalityError for these parts.","triggerScenarios":"Sending a 'file' part with data: { type: 'text', value: '...' } in a prompt to a Mistral model.","commonSituations":"Trying to pass text documents as file parts generically across providers; converting prompts written for providers that accept text file parts.","solutions":["Inline the text content as a regular text part instead of a file part.","If a document is required, send it as url or base64 data with a proper mediaType.","Convert text file parts to text parts in your prompt-building code.","Filter text file parts out for Mistral requests."],"exampleFix":"// before\n{ type: 'file', data: { type: 'text', value: 'Hello' } }\n// after\n{ type: 'text', text: 'Hello' }","handlingStrategy":"validation","validationCode":"function hasTextFilePart(messages: { content: unknown[] }[]): boolean {\n  return messages.some(m => (m.content as any[]).some(\n    p => p?.type === 'file' && p?.data?.type === 'text'));\n}\nif (hasTextFilePart(messages)) throw new Error('Convert text file parts to text parts for Mistral');","typeGuard":"function isTextFilePart(part: unknown): part is { type: 'file'; data: { type: 'text'; value: string } } {\n  return typeof part === 'object' && part !== null &&\n    (part as any).type === 'file' &&\n    (part as any).data?.type === 'text';\n}","tryCatchPattern":"try {\n  await generateText({ model: mistral(modelId), messages });\n} catch (error) {\n  if (UnsupportedFunctionalityError.isInstance(error) &&\n      error.functionality.includes('text file parts')) {\n    // convert file parts with text data into plain text parts and retry\n  } else {\n    throw error;\n  }\n}","preventionTips":["Use plain text parts for textual content instead of file parts.","Normalize prompts per provider before dispatch.","Add conversion tests covering every file data type you emit."],"tags":["mistral","unsupported-functionality","file-part","prompt-conversion"],"backgroundTag":"unsupported-provider-functionality","analyzedSha":"69428b1f8b037e4d118fb4853428d5c4e620493c","analyzedAt":"2026-08-30T12:32:21.016Z","schemaVersion":2},"datasetVersion":"2026-08-30T13:17:10.514Z"}