FlowiseAI/Flowise · error · Error

Please provide image as base64 encoded data URL

Error message

Please provide image as base64 encoded data URL

What it means

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.

Source

Thrown at packages/components/nodes/chatmodels/ChatGoogleGenerativeAI/FlowiseChatGoogleGenerativeAI.ts:259

    }

    if (content.type === 'text') {
        return { text: content.text }
    } else if (content.type === 'executableCode') {
        return { executableCode: (content as any).executableCode }
    } else if (content.type === 'codeExecutionResult') {
        return { codeExecutionResult: (content as any).codeExecutionResult }
    } else if (content.type === 'image_url') {
        if (!isMultimodalModel) {
            throw new Error(`This model does not support images`)
        }
        let source
        if (typeof content.image_url === 'string') {
            source = content.image_url
        } else if (typeof content.image_url === 'object' && 'url' in content.image_url) {
            source = content.image_url.url
        } else {
            throw new Error('Please provide image as base64 encoded data URL')
        }
        const [dm, data] = source.split(',')
        if (!dm.startsWith('data:')) {
            throw new Error('Please provide image as base64 encoded data URL')
        }
        const [mimeType, encoding] = dm.replace(/^data:/, '').split(';')
        if (encoding !== 'base64') {
            throw new Error('Please provide image as base64 encoded data URL')
        }
        return {
            inlineData: {
                data,
                mimeType
            }
        }
    } else if (content.type === 'media') {
        return messageContentMedia(content)
    } else if (content.type === 'tool_use') {

View on GitHub (pinned to abe4a8601a)

Solutions

  1. Ensure image_url is either a data-URL string or an object shaped { url: 'data:image/...;base64,...' }.
  2. Fix the producing node/tool to emit the standard image_url shape.
  3. Validate the part shape before sending messages to the Gemini node.

Example fix

// before (throws): { type:'image_url', image_url: { src: 'data:image/png;base64,...' } }
// after:           { type:'image_url', image_url: { url: 'data:image/png;base64,...' } }
Defensive patterns

Strategy: validation

Validate before calling

function extractImageUrlSource(block: any): string | null {
  if (typeof block.image_url === 'string') return block.image_url
  if (block.image_url && typeof block.image_url === 'object' && typeof block.image_url.url === 'string') {
    return block.image_url.url
  }
  return null
}
for (const p of parts) {
  if (p.type === 'image_url' && extractImageUrlSource(p) === null) {
    throw new Error('image_url must be a string or { url: string }')
  }
}

Type guard

type ImageUrlBlock =
  | { type: 'image_url'; image_url: string }
  | { type: 'image_url'; image_url: { url: string } }
function isImageUrlBlock(c: unknown): c is ImageUrlBlock {
  if (typeof c !== 'object' || c === null || (c as any).type !== 'image_url') return false
  const iu = (c as any).image_url
  return typeof iu === 'string' || (typeof iu === 'object' && iu !== null && typeof iu.url === 'string')
}

Try / catch

try {
  return _convertLangChainContentToPart(part, isMultimodal)
} catch (e) {
  if (e instanceof Error && /base64 encoded data URL/.test(e.message)) {
    // repair the image_url shape or drop the part
  }
  throw e
}

Prevention

When it happens

Trigger: content.image_url is something other than a string or { url: string } (e.g., a number, an object without 'url', or undefined).

Common situations: 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').

Related errors


AI-assisted analysis of FlowiseAI/Flowise@abe4a8601a (2026-08-12). Data as JSON: /api/errors/0c8a7b7e6941e22e. Report an issue: GitHub.