{"record":{"id":"55e98d29d3aa641f","repo":"vercel/ai","slug":"file-url-data","errorCode":null,"errorMessage":"File URL data","messagePattern":"File URL data","errorType":"exception","errorClass":"UnsupportedFunctionalityError","httpStatus":null,"severity":"error","filePath":"packages/amazon-bedrock/src/convert-to-amazon-bedrock-chat-messages.ts","lineNumber":233,"sourceCode":"                      });\n                    } else {\n                      amazonBedrockContent.push({\n                        text: part.text,\n                      });\n                    }\n                    break;\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 'url': {\n                        if (part.data.url.protocol !== 's3:') {\n                          throw new UnsupportedFunctionalityError({\n                            functionality: 'File URL data',\n                          });\n                        }\n\n                        const fullMediaType = resolveFullMediaType({ part });\n\n                        switch (getTopLevelMediaType(fullMediaType)) {\n                          case 'image': {\n                            amazonBedrockContent.push({\n                              image: {\n                                format:\n                                  getAmazonBedrockImageFormat(fullMediaType),\n                                source: getAmazonBedrockMediaSource({\n                                  data: part.data,\n                                  functionality: 'File URL data',\n                                }),\n                              },\n                            });","sourceCodeStart":215,"sourceCodeEnd":251,"githubUrl":"https://github.com/vercel/ai/blob/69428b1f8b037e4d118fb4853428d5c4e620493c/packages/amazon-bedrock/src/convert-to-amazon-bedrock-chat-messages.ts#L215-L251","documentation":"When a file part's data is a URL, Bedrock only supports S3 URLs. Any other protocol (https:, data:, etc.) triggers this UnsupportedFunctionalityError labelled 'File URL data', because non-S3 URL file sources cannot be translated to the Bedrock payload.","triggerScenarios":"Passing a file part with `data: { type: 'url', url: new URL('https://...') }` (or any non-s3: protocol) in a message sent to a Bedrock model.","commonSituations":"Reusing public HTTPS document URLs from prompts built for OpenAI/Anthropic direct upload APIs; assuming URL-based file input works everywhere; data: URIs embedded in messages.","solutions":["Change the URL to an s3:// protocol URL pointing at a bucket accessible by your Bedrock account.","Otherwise download the file and pass its bytes as raw data (Uint8Array) in the file part.","For web-hosted files, fetch them server-side first and embed the content."],"exampleFix":"// before\n{ type: 'file', data: { type: 'url', url: new URL('https://example.com/doc.pdf') } }\n// after (option A)\n{ type: 'file', data: { type: 'url', url: new URL('s3://my-bucket/doc.pdf') } }\n// after (option B)\nconst bytes = new Uint8Array(await (await fetch('https://example.com/doc.pdf')).arrayBuffer());\n{ type: 'file', data: bytes, mediaType: 'application/pdf' }","handlingStrategy":"validation","validationCode":"function assertFileUrlProtocol(messages) {\n  for (const m of messages) {\n    const parts = Array.isArray(m.content) ? m.content : [];\n    for (const p of parts) {\n      if (p.type === 'file' && p.data?.type === 'url' && p.data.url.protocol !== 's3:') {\n        throw new Error('Bedrock only supports s3:// URLs for file parts; use raw bytes for other sources.');\n      }\n    }\n  }\n}","typeGuard":"function isS3FileUrl(part: any): boolean {\n  return part?.type === 'file' && part?.data?.type === 'url' && part?.data?.url?.protocol === 's3:';\n}","tryCatchPattern":"try {\n  await generateText({ model: bedrock(modelId), messages });\n} catch (error) {\n  if (UnsupportedFunctionalityError.isInstance(error) && error.functionality === 'File URL data') {\n    // download the URL server-side, embed bytes, retry\n  } else {\n    throw error;\n  }\n}","preventionTips":["Upload documents to S3 and reference them via s3:// URLs when working with Bedrock.","For non-S3 sources, fetch bytes server-side and pass raw data before calling the model.","Normalize incoming file parts with a pre-processing step that converts https/data URLs to bytes."],"tags":["bedrock","file-parts","s3","unsupported-functionality"],"backgroundTag":"unsupported-functionality","analyzedSha":"69428b1f8b037e4d118fb4853428d5c4e620493c","analyzedAt":"2026-08-30T12:32:21.016Z","schemaVersion":2},"datasetVersion":"2026-08-30T13:17:10.514Z"}