{"record":{"id":"4b49389cd60e4f62","repo":"vercel/ai","slug":"file-parts-with-provider-references","errorCode":null,"errorMessage":"file parts with provider references","messagePattern":"file parts with provider references","errorType":"exception","errorClass":"UnsupportedFunctionalityError","httpStatus":null,"severity":"error","filePath":"packages/amazon-bedrock/src/convert-to-amazon-bedrock-chat-messages.ts","lineNumber":227,"sourceCode":"                        guardContent: {\n                          text: {\n                            text: part.text,\n                            qualifiers: textOptions.guardContentQualifiers,\n                          },\n                        },\n                      });\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),","sourceCodeStart":209,"sourceCodeEnd":245,"githubUrl":"https://github.com/vercel/ai/blob/69428b1f8b037e4d118fb4853428d5c4e620493c/packages/amazon-bedrock/src/convert-to-amazon-bedrock-chat-messages.ts#L209-L245","documentation":"File parts whose data is a provider reference (a previously uploaded file referenced by provider-specific ID) have no representation in the Bedrock chat payload, so the converter throws UnsupportedFunctionalityError with 'file parts with provider references'.","triggerScenarios":"Sending a message containing a file part with `data: { type: 'reference' }` (e.g. a file stored/uploaded via another provider's file API) to a Bedrock model via generateText/streamText.","commonSituations":"Reusing prompts built for OpenAI file IDs; multi-provider apps sharing message arrays that contain references; tool results carrying provider file references.","solutions":["Send the file as raw binary data instead: use a Uint8Array/Buffer in the file part's data.","For S3-hosted files, use a URL part with an s3: protocol URL.","Convert provider references to actual bytes before calling the Bedrock model."],"exampleFix":"// before\n{ type: 'file', data: new Uint8Array(...), mediaType: 'application/pdf' } // ok\n{ type: 'file', data: { type: 'reference', fileId: 'file-abc' } } // throws\n// after\nconst bytes = await fetchStoredFileBytes('file-abc');\n{ type: 'file', data: bytes, mediaType: 'application/pdf' }","handlingStrategy":"validation","validationCode":"function assertNoFileReferences(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 === 'reference') {\n        throw new Error('Bedrock cannot consume file parts by reference; send raw bytes or an s3:// URL.');\n      }\n    }\n  }\n}","typeGuard":"function isFileReference(part: any): part is { type: 'file'; data: { type: 'reference'; fileId: string } } {\n  return part?.type === 'file' && part?.data?.type === 'reference';\n}","tryCatchPattern":"try {\n  await streamText({ model: bedrock(modelId), messages });\n} catch (error) {\n  if (UnsupportedFunctionalityError.isInstance(error) && error.functionality.includes('provider references')) {\n    // resolve reference to bytes and rebuild the message\n  } else {\n    throw error;\n  }\n}","preventionTips":["Resolve provider file references to raw bytes before dispatching to any provider-agnostic pipeline.","Keep per-provider capability checks when routing shared message arrays to different models.","Prefer binary data or s3:// URLs for Bedrock file inputs from the start."],"tags":["bedrock","file-parts","unsupported-functionality"],"backgroundTag":"unsupported-functionality","analyzedSha":"69428b1f8b037e4d118fb4853428d5c4e620493c","analyzedAt":"2026-08-30T12:32:21.016Z","schemaVersion":2},"datasetVersion":"2026-08-30T13:17:10.514Z"}