{"record":{"id":"9bcf507440e65e85","repo":"n8n-io/n8n","slug":"invalid-message-type-only-imagebinary-and-imageur","errorCode":null,"errorMessage":"Invalid message type. Only imageBinary and imageUrl are supported","messagePattern":"Invalid message type\\. Only imageBinary and imageUrl are supported","errorType":"exception","errorClass":"NodeOperationError","httpStatus":null,"severity":"error","filePath":"packages/@n8n/nodes-langchain/nodes/chains/ChainLLM/methods/imageUtils.ts","lineNumber":38,"sourceCode":"\t}\n\treturn `data:${binaryData.mimeType};base64,${bufferData.toString('base64')}`;\n}\n\n/**\n * Creates a human message with image content from either binary data or URL\n */\nexport async function createImageMessage({\n\tcontext,\n\titemIndex,\n\tmessage,\n}: {\n\tcontext: IExecuteFunctions;\n\titemIndex: number;\n\tmessage: MessageTemplate;\n}): Promise<HumanMessage> {\n\t// Validate message type\n\tif (message.messageType !== 'imageBinary' && message.messageType !== 'imageUrl') {\n\t\tthrow new NodeOperationError(\n\t\t\tcontext.getNode(),\n\t\t\t'Invalid message type. Only imageBinary and imageUrl are supported',\n\t\t);\n\t}\n\n\tconst detail = message.imageDetail === 'auto' ? undefined : message.imageDetail;\n\n\t// Handle image URL case\n\tif (message.messageType === 'imageUrl' && message.imageUrl) {\n\t\treturn new HumanMessage({\n\t\t\tcontent: [\n\t\t\t\t{\n\t\t\t\t\ttype: 'image_url',\n\t\t\t\t\timage_url: {\n\t\t\t\t\t\turl: message.imageUrl,\n\t\t\t\t\t\tdetail,\n\t\t\t\t\t},\n\t\t\t\t},","sourceCodeStart":20,"sourceCodeEnd":56,"githubUrl":"https://github.com/n8n-io/n8n/blob/5ac6606e81f67bb9534255570cd4e86fd8101eee/packages/@n8n/nodes-langchain/nodes/chains/ChainLLM/methods/imageUtils.ts#L20-L56","documentation":"createImageMessage throws a NodeOperationError when message.messageType is neither 'imageBinary' nor 'imageUrl'. The function only knows how to construct an image content block for a HumanMessage, so any other message type value is rejected before any work begins.","triggerScenarios":"A message template configured on the Basic LLM Chain has its type set to 'human' (so it routes into createImageMessage via promptUtils) but its messageType is 'text', 'audio', or some legacy/typo value, rather than 'imageBinary' or 'imageUrl'.","commonSituations":"The user added a message row intended for text but the promptUtils routing dispatched it to createImageMessage, or a workflow exported from an older node version has a messageType value that no longer exists. A typo in a fixedCollection value (e.g. 'imageBinry') also triggers this.","solutions":["Open the Basic LLM Chain 'Messages' setting and confirm each human message's messageType is exactly 'imageBinary' or 'imageUrl'.","If the message should be plain text, set the message type so promptUtils does not route it to createImageMessage (i.e. leave messageType as 'text').","Recreate the message row from scratch instead of editing a stale value to avoid hidden fixedCollection state.","Check the node typeVersion; workflows from older versions may need to be migrated/re-added."],"exampleFix":"// before\nif (message.messageType !== 'imageBinary' && message.messageType !== 'imageUrl') {\n  throw new NodeOperationError(context.getNode(), 'Invalid message type. Only imageBinary and imageUrl are supported');\n}\n\n// after — list the accepted values in the error so the user can self-correct\nconst VALID = ['imageBinary', 'imageUrl'] as const;\nif (!VALID.includes(message.messageType as any)) {\n  throw new NodeOperationError(context.getNode(), {\n    message: `Invalid message type '${message.messageType}'. Expected one of: ${VALID.join(', ')}.`,\n    itemIndex,\n  });\n}","handlingStrategy":"validation","validationCode":"const VALID_IMAGE_MESSAGE_TYPES = new Set(['imageBinary', 'imageUrl']);\nfunction isValidImageMessageType(t: string): boolean {\n  return VALID_IMAGE_MESSAGE_TYPES.has(t);\n}\n// before saving the message template\nif (!isValidImageMessageType(message.messageType)) {\n  throw new Error(`messageType must be imageBinary or imageUrl, got ${message.messageType}`);\n}","typeGuard":"function isImageMessageType(t: unknown): t is 'imageBinary' | 'imageUrl' {\n  return t === 'imageBinary' || t === 'imageUrl';\n}","tryCatchPattern":null,"preventionTips":["When authoring message templates programmatically, restrict messageType to the two valid values.","Recreate message rows in the UI rather than hand-editing the workflow JSON.","Avoid reusing text-message rows for image messages; add a fresh image row."],"tags":["configuration","message-template","vision-model","parameter-validation"],"backgroundTag":null,"analyzedSha":"5ac6606e81f67bb9534255570cd4e86fd8101eee","analyzedAt":"2026-08-12T05:26:35.080Z","schemaVersion":2},"datasetVersion":"2026-08-12T13:17:24.610Z"}