{"record":{"id":"e0540bef48712835","repo":"vercel/ai","slug":"tool-result-file-data-of-type-contentpart-data","errorCode":null,"errorMessage":"tool result file data of type \"${contentPart.data.type}\"","messagePattern":"tool result file data of type \"(.+?)\"","errorType":"exception","errorClass":"UnsupportedFunctionalityError","httpStatus":null,"severity":"error","filePath":"packages/amazon-bedrock/src/convert-to-amazon-bedrock-chat-messages.ts","lineNumber":400,"sourceCode":"                  continue;\n                }\n                let toolResultContent;\n\n                const output = part.output;\n                switch (output.type) {\n                  case 'content': {\n                    toolResultContent = await Promise.all(\n                      output.value.map(async contentPart => {\n                        switch (contentPart.type) {\n                          case 'text':\n                            return { text: contentPart.text };\n                          case 'file': {\n                            if (\n                              contentPart.data.type !== 'data' &&\n                              (contentPart.data.type !== 'url' ||\n                                contentPart.data.url.protocol !== 's3:')\n                            ) {\n                              throw new UnsupportedFunctionalityError({\n                                functionality: `tool result file data of type \"${contentPart.data.type}\"`,\n                              });\n                            }\n\n                            const fullMediaType = resolveFullMediaType({\n                              part: contentPart,\n                            });\n\n                            switch (getTopLevelMediaType(fullMediaType)) {\n                              case 'image': {\n                                return {\n                                  image: {\n                                    format:\n                                      getAmazonBedrockImageFormat(\n                                        fullMediaType,\n                                      ),\n                                    source: getAmazonBedrockMediaSource({\n                                      data: contentPart.data,","sourceCodeStart":382,"sourceCodeEnd":418,"githubUrl":"https://github.com/vercel/ai/blob/69428b1f8b037e4d118fb4853428d5c4e620493c/packages/amazon-bedrock/src/convert-to-amazon-bedrock-chat-messages.ts#L382-L418","documentation":"In tool-result conversion, a file part is only accepted when it is inline 'data' or an 's3:' protocol URL. Any other type (e.g. a plain https URL, or other data carrier types) triggers UnsupportedFunctionalityError with the offending data type in the message. Bedrock cannot fetch arbitrary web URLs for tool result files.","triggerScenarios":"A tool returns a file part whose contentPart.data.type is neither 'data' nor 'url' with an s3: protocol — most commonly an https URL file inside a tool result.","commonSituations":"A tool fetches a document from the web and returns its URL as a file part; Bedrock requires the bytes (inline data) or an S3 location instead.","solutions":["Return the file as inline 'data' (base64/Uint8Array) from the tool with a supported media type.","Upload the file to S3 and return a file part with an s3:// URL.","Convert the file content to text and return it as a text tool result part instead.","Verify the tool result file part shape matches the AI SDK FilePart data union."],"exampleFix":"// before (in tool result content)\n{ type: 'file', mediaType: 'application/pdf', data: new URL('https://cdn.example.com/report.pdf') }\n// after\n{ type: 'file', mediaType: 'application/pdf', data: await downloadBytes('https://cdn.example.com/report.pdf'), filename: 'report.pdf' }","handlingStrategy":"validation","validationCode":"function validateToolResultFile(part) {\n  if (part.type !== 'file') return true;\n  const ok = part.data.type === 'data' || (part.data.type === 'url' && part.data.url.protocol === 's3:');\n  if (!ok) throw new Error(`Tool result file must be inline data or s3: URL, got: ${part.data.type}`);\n  return true;\n}","typeGuard":"function isInlineOrS3FileData(data) {\n  return data.type === 'data' || (data.type === 'url' && data.url.protocol === 's3:');\n}","tryCatchPattern":"try {\n  return await generateText({ model, prompt });\n} catch (error) {\n  if (UnsupportedFunctionalityError.isInstance(error) && error.message.includes('tool result file data')) {\n    console.error('Tool returned an unsupported file data type; inline the bytes or use s3://.');\n  }\n  throw error;\n}","preventionTips":["Design tools to return file bytes inline or S3 URIs, never web URLs.","Add a unit test for every tool's output shape against the Bedrock converter.","Wrap tool execute() to normalize file parts before they reach the provider."],"tags":["unsupported-functionality","bedrock","tool-result","file-data"],"backgroundTag":"unsupported-media-type","analyzedSha":"69428b1f8b037e4d118fb4853428d5c4e620493c","analyzedAt":"2026-08-30T12:32:21.016Z","schemaVersion":2},"datasetVersion":"2026-08-30T13:17:10.514Z"}