{"record":{"id":"f70c24d770c9007a","repo":"continuedev/continue","slug":"anthropic-skipping-image-with-invalid-data-url-fo-f70c24","errorCode":null,"errorMessage":"Anthropic: skipping image with invalid data URL format","messagePattern":"Anthropic: skipping image with invalid data URL format","errorType":"console","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"packages/openai-adapters/src/apis/Anthropic.ts","lineNumber":218,"sourceCode":"        (p) =>\n          p.type === \"text\" || p.type === \"image_url\" || p.type === \"refusal\",\n      );\n      for (const part of supportedParts) {\n        if (part.type === \"image_url\") {\n          const dataUrl = part.image_url.url;\n          if (dataUrl?.startsWith(\"data:\")) {\n            const base64Data = extractBase64FromDataUrl(dataUrl);\n            if (base64Data) {\n              blocks.push({\n                type: \"image\",\n                source: {\n                  type: \"base64\",\n                  media_type: getAnthropicMediaTypeFromDataUrl(dataUrl),\n                  data: base64Data,\n                },\n              });\n            } else {\n              console.warn(\n                \"Anthropic: skipping image with invalid data URL format\",\n                dataUrl,\n              );\n            }\n          }\n        } else {\n          const text = part.type === \"text\" ? part.text : part.refusal;\n          if (text) {\n            blocks.push({\n              type: \"text\",\n              text,\n            });\n          }\n        }\n      }\n    }\n    return blocks;\n  }","sourceCodeStart":200,"sourceCodeEnd":236,"githubUrl":"https://github.com/continuedev/continue/blob/5522c6f44ca0ac3528b37244818fbfa39b5af470/packages/openai-adapters/src/apis/Anthropic.ts#L200-L236","documentation":"convertMessageContentToBlocks converts OpenAI-style multimodal messages to Anthropic blocks. For an image_url part, it attempts to parse the data URL; when parsing fails (not a valid data:...;base64,<data> URL), the image is skipped from the request with this warning and the rest of the message is sent without it.","triggerScenarios":"Sending a ChatMessage whose content includes an image_url with an http(s) URL instead of a data URL, a malformed base64 payload, or a data URL missing the base64 marker or media type.","commonSituations":"Passing remote image URLs (Anthropic's OpenAI-compat path here requires data URLs), hand-building data URLs with typos, or double-encoding base64.","solutions":["Convert remote images to data URLs first: fetch the bytes and build `data:<mime>;base64,<b64>`","Validate the data URL shape before sending (regex or URL parsing: scheme data:, `;base64,` marker present)","Ensure the media type is one Anthropic supports (image/jpeg, image/png, image/gif, image/webp)","Check that base64 data was not URL-encoded or truncated"],"exampleFix":"// before\n{ type: \"image_url\", image_url: { url: \"https://example.com/cat.png\" } }\n\n// after\nconst b64 = fs.readFileSync(\"cat.png\").toString(\"base64\");\n{ type: \"image_url\", image_url: { url: `data:image/png;base64,${b64}` } }","handlingStrategy":"type-guard","validationCode":"const ok = /^data:[\\w./+-]+;base64,[A-Za-z0-9+/=]+$/.test(url);","typeGuard":"const isDataUrl = (u: string): u is `data:${string};base64,${string}` =>\n  /^data:[\\w./+-]+;base64,[A-Za-z0-9+/=]+$/.test(u);","tryCatchPattern":null,"preventionTips":["Convert remote URLs to base64 data URLs before sending to Anthropic","Validate data URL structure and MIME type (jpeg/png/gif/webp) upfront","Watch for skipped-image warnings in logs to catch silent vision failures"],"tags":["anthropic","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"}