{"record":{"id":"69cc811427a6d053","repo":"FlowiseAI/Flowise","slug":"unsupported-message-input","errorCode":null,"errorMessage":"Unsupported message input","messagePattern":"Unsupported message input","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/components/nodes/chatmodels/ChatGoogleGenerativeAI/FlowiseChatGoogleGenerativeAI.ts","lineNumber":413,"sourceCode":"        })\n    }\n\n    return [...messageParts, ...functionCalls]\n}\n\nexport function convertBaseMessagesToContent(\n    messages: BaseMessage[],\n    isMultimodalModel: boolean,\n    convertSystemMessageToHumanContent: boolean = false,\n    model?: string\n) {\n    return messages.reduce<{\n        content: Content[]\n        mergeWithPreviousContent: boolean\n    }>(\n        (acc, message, index) => {\n            if (!BaseMessage.isInstance(message)) {\n                throw new Error('Unsupported message input')\n            }\n            const author = getMessageAuthor(message)\n            if (author === 'system' && index !== 0) {\n                throw new Error('System message should be the first one')\n            }\n            const role = convertAuthorToRole(author)\n\n            const prevContent = acc.content[acc.content.length]\n            if (!acc.mergeWithPreviousContent && prevContent && prevContent.role === role) {\n                throw new Error('Google Generative AI requires alternate messages between authors')\n            }\n\n            const parts = convertMessageContentToParts(message, isMultimodalModel, messages.slice(0, index), model)\n\n            if (acc.mergeWithPreviousContent) {\n                const prevContent = acc.content[acc.content.length - 1]\n                if (!prevContent) {\n                    throw new Error('There was a problem parsing your system message. Please try a prompt without one.')","sourceCodeStart":395,"sourceCodeEnd":431,"githubUrl":"https://github.com/FlowiseAI/Flowise/blob/abe4a8601a058047b350c260676826e21dd14101/packages/components/nodes/chatmodels/ChatGoogleGenerativeAI/FlowiseChatGoogleGenerativeAI.ts#L395-L431","documentation":"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.","triggerScenarios":"The messages array passed to the Gemini model contains a non-BaseMessage element (a raw {role, content} object, a string, null, etc.).","commonSituations":"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.","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."],"exampleFix":"// before (throws): messages = [{ role: 'user', content: 'hi' }]\n// after:           messages = [new HumanMessage('hi')]","handlingStrategy":"type-guard","validationCode":"import { BaseMessage } from '@langchain/core/messages'\n\nfunction allAreBaseMessages(msgs: unknown[]): boolean {\n  return msgs.every((m) => BaseMessage.isInstance(m))\n}\nif (!allAreBaseMessages(messages)) {\n  throw new Error('All messages must be LangChain BaseMessage instances')\n}","typeGuard":"import { BaseMessage } from '@langchain/core/messages'\nfunction isBaseMessageArray(msgs: unknown): msgs is BaseMessage[] {\n  return Array.isArray(msgs) && msgs.every((m) => BaseMessage.isInstance(m))\n}","tryCatchPattern":"try {\n  return convertBaseMessagesToContent(messages, isMultimodal, false)\n} catch (e) {\n  if (e instanceof Error && e.message === 'Unsupported message input') {\n    // rehydrate with BaseMessage.fromJSON or filter to BaseMessage instances and retry\n  }\n  throw e\n}","preventionTips":["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."],"tags":["gemini","messages","validation","dispatch"],"backgroundTag":null,"analyzedSha":"abe4a8601a058047b350c260676826e21dd14101","analyzedAt":"2026-08-12T16:04:40.823Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}