{"record":{"id":"0c8a7b7e6941e22e","repo":"FlowiseAI/Flowise","slug":"please-provide-image-as-base64-encoded-data-url","errorCode":null,"errorMessage":"Please provide image as base64 encoded data URL","messagePattern":"Please provide image as base64 encoded data URL","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/components/nodes/chatmodels/ChatGoogleGenerativeAI/FlowiseChatGoogleGenerativeAI.ts","lineNumber":259,"sourceCode":"    }\n\n    if (content.type === 'text') {\n        return { text: content.text }\n    } else if (content.type === 'executableCode') {\n        return { executableCode: (content as any).executableCode }\n    } else if (content.type === 'codeExecutionResult') {\n        return { codeExecutionResult: (content as any).codeExecutionResult }\n    } else if (content.type === 'image_url') {\n        if (!isMultimodalModel) {\n            throw new Error(`This model does not support images`)\n        }\n        let source\n        if (typeof content.image_url === 'string') {\n            source = content.image_url\n        } else if (typeof content.image_url === 'object' && 'url' in content.image_url) {\n            source = content.image_url.url\n        } else {\n            throw new Error('Please provide image as base64 encoded data URL')\n        }\n        const [dm, data] = source.split(',')\n        if (!dm.startsWith('data:')) {\n            throw new Error('Please provide image as base64 encoded data URL')\n        }\n        const [mimeType, encoding] = dm.replace(/^data:/, '').split(';')\n        if (encoding !== 'base64') {\n            throw new Error('Please provide image as base64 encoded data URL')\n        }\n        return {\n            inlineData: {\n                data,\n                mimeType\n            }\n        }\n    } else if (content.type === 'media') {\n        return messageContentMedia(content)\n    } else if (content.type === 'tool_use') {","sourceCodeStart":241,"sourceCodeEnd":277,"githubUrl":"https://github.com/FlowiseAI/Flowise/blob/abe4a8601a058047b350c260676826e21dd14101/packages/components/nodes/chatmodels/ChatGoogleGenerativeAI/FlowiseChatGoogleGenerativeAI.ts#L241-L277","documentation":"Thrown in _convertLangChainContentToPart (line 259) for content.type === 'image_url' when the image_url value is neither a string nor an object with a 'url' key. This is the first of three base64-URL guards on this branch; it fires when no usable source string can be extracted at all.","triggerScenarios":"content.image_url is something other than a string or { url: string } (e.g., a number, an object without 'url', or undefined).","commonSituations":"A malformed image_url part produced by a tool or upstream node, or a schema where the URL lives under a different key (e.g., 'src').","solutions":["Ensure image_url is either a data-URL string or an object shaped { url: 'data:image/...;base64,...' }.","Fix the producing node/tool to emit the standard image_url shape.","Validate the part shape before sending messages to the Gemini node."],"exampleFix":"// before (throws): { type:'image_url', image_url: { src: 'data:image/png;base64,...' } }\n// after:           { type:'image_url', image_url: { url: 'data:image/png;base64,...' } }","handlingStrategy":"validation","validationCode":"function extractImageUrlSource(block: any): string | null {\n  if (typeof block.image_url === 'string') return block.image_url\n  if (block.image_url && typeof block.image_url === 'object' && typeof block.image_url.url === 'string') {\n    return block.image_url.url\n  }\n  return null\n}\nfor (const p of parts) {\n  if (p.type === 'image_url' && extractImageUrlSource(p) === null) {\n    throw new Error('image_url must be a string or { url: string }')\n  }\n}","typeGuard":"type ImageUrlBlock =\n  | { type: 'image_url'; image_url: string }\n  | { type: 'image_url'; image_url: { url: string } }\nfunction isImageUrlBlock(c: unknown): c is ImageUrlBlock {\n  if (typeof c !== 'object' || c === null || (c as any).type !== 'image_url') return false\n  const iu = (c as any).image_url\n  return typeof iu === 'string' || (typeof iu === 'object' && iu !== null && typeof iu.url === 'string')\n}","tryCatchPattern":"try {\n  return _convertLangChainContentToPart(part, isMultimodal)\n} catch (e) {\n  if (e instanceof Error && /base64 encoded data URL/.test(e.message)) {\n    // repair the image_url shape or drop the part\n  }\n  throw e\n}","preventionTips":["Always shape image_url as a string or { url } object at the producer.","Reject image_url blocks with unrecognized shapes before the Gemini call.","Add a producer contract test for image_url parts."],"tags":["gemini","multimodal","images","content-blocks","validation"],"backgroundTag":null,"analyzedSha":"abe4a8601a058047b350c260676826e21dd14101","analyzedAt":"2026-08-12T16:04:40.823Z","schemaVersion":2},"datasetVersion":"2026-08-12T18:17:37.767Z"}