{"record":{"id":"588e18f7748455c4","repo":"continuedev/continue","slug":"bedrock-failed-to-process-image-part-invalid-ur","errorCode":null,"errorMessage":"Bedrock: failed to process image part - invalid URL","messagePattern":"Bedrock: failed to process image part - invalid URL","errorType":"console","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"packages/openai-adapters/src/apis/Bedrock.ts","lineNumber":142,"sourceCode":"  ): ContentBlock {\n    switch (part.type) {\n      case \"refusal\":\n        return {\n          text: part.refusal,\n        };\n      case \"text\":\n        return {\n          text: part.text,\n        };\n      case \"input_audio\":\n        throw new Error(\"Unsupported part type: input_audio\");\n      case \"image_url\":\n      default:\n        const parsed = parseDataUrl(\n          (part as ChatCompletionContentPartImage).image_url.url,\n        );\n        if (!parsed) {\n          console.warn(\"Bedrock: failed to process image part - invalid URL\");\n          return { text: \"[Failed to process image]\" };\n        }\n        const { mimeType, base64Data } = parsed;\n        const format = mimeType.split(\"/\")[1]?.split(\";\")[0] || \"jpeg\";\n        if (\n          format === ImageFormat.JPEG ||\n          format === ImageFormat.PNG ||\n          format === ImageFormat.WEBP ||\n          format === ImageFormat.GIF\n        ) {\n          return {\n            image: {\n              format,\n              source: {\n                bytes: Uint8Array.from(Buffer.from(base64Data, \"base64\")),\n              },\n            },\n          };","sourceCodeStart":124,"sourceCodeEnd":160,"githubUrl":"https://github.com/continuedev/continue/blob/5522c6f44ca0ac3528b37244818fbfa39b5af470/packages/openai-adapters/src/apis/Bedrock.ts#L124-L160","documentation":"While converting OpenAI message parts to Bedrock Converse parts, _oaiPartToBedrockPart parses the image_url as a data URL via parseDataUrl. If parsing returns null (malformed data URL), the image part is replaced with the placeholder text \"[Failed to process image]\" and this warning is logged, so the request still goes through but without the image.","triggerScenarios":"Sending an image_url part with an http(s) URL, a data URL missing the `;base64,` marker, an unsupported/missing MIME type, or corrupted base64 payload to a Bedrock model.","commonSituations":"Reusing OpenAI-compatible payloads (which allow remote URLs) against Bedrock, which requires inline base64 data URLs; truncated base64 from string manipulation.","solutions":["Inline the image as a data URL: `data:image/jpeg;base64,<b64data>`","Validate the data URL before sending (regex for ^data:[\\w./+-]+;base64,[A-Za-z0-9+/=]+$)","Use a supported format (jpeg/png/gif/webp) in the data URL MIME type","Re-encode the image to base64 to ensure the payload is valid"],"exampleFix":"// before\n{ type: \"image_url\", image_url: { url: remoteUrl } }\n\n// after\nconst b64 = (await fetch(remoteUrl)).arrayBuffer() |> Buffer.from |> (b) => b.toString(\"base64\");\n{ type: \"image_url\", image_url: { url: `data:image/png;base64,${b64}` } }","handlingStrategy":"validation","validationCode":"if (!part.image_url.url.startsWith(\"data:\")) {\n  throw new Error(\"Bedrock requires inline base64 data URLs for images\");\n}","typeGuard":"const isDataUrl = (u: string): u is `data:${string};base64,${string}` =>\n  /^data:[\\w./+-]+;base64,[A-Za-z0-9+/=]+$/.test(u);","tryCatchPattern":null,"preventionTips":["Always inline images as base64 data URLs for Bedrock","Validate MIME is jpeg/png/gif/webp before sending","Log placeholders like [Failed to process image] in responses to detect silent drops"],"tags":["bedrock","vision","data-url","multimodal"],"backgroundTag":"invalid-image-data-url","analyzedSha":"5522c6f44ca0ac3528b37244818fbfa39b5af470","analyzedAt":"2026-08-27T11:28:54.683Z","schemaVersion":2},"datasetVersion":"2026-08-27T13:17:12.746Z"}