FlowiseAI/Flowise · error · Error
Unsupported message input
Error message
Unsupported message input
What it means
Thrown in convertBaseMessagesToContent (line 413) when an element of the messages array fails BaseMessage.isInstance(message). The converter expects every entry to be a LangChain BaseMessage instance (HumanMessage, AIMessage, SystemMessage, ToolMessage, etc.); plain objects or strings are rejected before author/role mapping.
Source
Thrown at packages/components/nodes/chatmodels/ChatGoogleGenerativeAI/FlowiseChatGoogleGenerativeAI.ts:413
})
}
return [...messageParts, ...functionCalls]
}
export function convertBaseMessagesToContent(
messages: BaseMessage[],
isMultimodalModel: boolean,
convertSystemMessageToHumanContent: boolean = false,
model?: string
) {
return messages.reduce<{
content: Content[]
mergeWithPreviousContent: boolean
}>(
(acc, message, index) => {
if (!BaseMessage.isInstance(message)) {
throw new Error('Unsupported message input')
}
const author = getMessageAuthor(message)
if (author === 'system' && index !== 0) {
throw new Error('System message should be the first one')
}
const role = convertAuthorToRole(author)
const prevContent = acc.content[acc.content.length]
if (!acc.mergeWithPreviousContent && prevContent && prevContent.role === role) {
throw new Error('Google Generative AI requires alternate messages between authors')
}
const parts = convertMessageContentToParts(message, isMultimodalModel, messages.slice(0, index), model)
if (acc.mergeWithPreviousContent) {
const prevContent = acc.content[acc.content.length - 1]
if (!prevContent) {
throw new Error('There was a problem parsing your system message. Please try a prompt without one.')View on GitHub (pinned to abe4a8601a)
Solutions
- Construct messages with LangChain classes: new HumanMessage(...), new AIMessage(...), etc.
- If loading from storage, rehydrate with BaseMessage.fromJSON() / HumanMessage.fromJSON() before passing.
- Filter the array to only BaseMessage instances before the call.
Example fix
// before (throws): messages = [{ role: 'user', content: 'hi' }]
// after: messages = [new HumanMessage('hi')] Defensive patterns
Strategy: type-guard
Validate before calling
import { BaseMessage } from '@langchain/core/messages'
function allAreBaseMessages(msgs: unknown[]): boolean {
return msgs.every((m) => BaseMessage.isInstance(m))
}
if (!allAreBaseMessages(messages)) {
throw new Error('All messages must be LangChain BaseMessage instances')
} Type guard
import { BaseMessage } from '@langchain/core/messages'
function isBaseMessageArray(msgs: unknown): msgs is BaseMessage[] {
return Array.isArray(msgs) && msgs.every((m) => BaseMessage.isInstance(m))
} Try / catch
try {
return convertBaseMessagesToContent(messages, isMultimodal, false)
} catch (e) {
if (e instanceof Error && e.message === 'Unsupported message input') {
// rehydrate with BaseMessage.fromJSON or filter to BaseMessage instances and retry
}
throw e
} Prevention
- Construct messages with HumanMessage/AIMessage/SystemMessage/ToolMessage classes only.
- Rehydrate persisted messages with BaseMessage.fromJSON before invoking the model.
- Filter the array to BaseMessage instances before the call to fail early with a clearer error.
When it happens
Trigger: The messages array passed to the Gemini model contains a non-BaseMessage element (a raw {role, content} object, a string, null, etc.).
Common situations: Messages were constructed as plain OpenAI-style objects, a serialization/deserialization round-trip replaced instances with POJOs, or a null/undefined leaked into the array.
Related errors
- Unknown content type ${content.type}
- Unknown content ${JSON.stringify(content)}
- Google requires a tool name for each tool call response, and
- Invalid media content
- Unsupported source type: ${block.source_type}
AI-assisted analysis of FlowiseAI/Flowise@abe4a8601a (2026-08-12).
Data as JSON: /api/errors/69cc811427a6d053.
Report an issue: GitHub.