{"record":{"id":"98127f35e37ff58d","repo":"n8n-io/n8n","slug":"a-non-empty-prompt-is-required-98127f","errorCode":null,"errorMessage":"A non-empty prompt is required.","messagePattern":"A non-empty prompt is required\\.","errorType":"exception","errorClass":"NodeOperationError","httpStatus":null,"severity":"error","filePath":"packages/@n8n/nodes-langchain/nodes/vendors/OpenAi/v1/actions/text/message.operation.ts","lineNumber":245,"sourceCode":"\t\t],\n\t},\n];\n\nconst displayOptions = {\n\tshow: {\n\t\toperation: ['message'],\n\t\tresource: ['text'],\n\t},\n};\n\nexport const description = updateDisplayOptions(displayOptions, properties);\n\nexport async function execute(this: IExecuteFunctions, i: number): Promise<INodeExecutionData[]> {\n\tconst nodeVersion = this.getNode().typeVersion;\n\tconst model = this.getNodeParameter('modelId', i, '', { extractValue: true });\n\tlet messages = this.getNodeParameter('messages.values', i, []) as IDataObject[];\n\tif (!messages.some((m) => typeof m.content === 'string' && m.content.trim() !== '')) {\n\t\tthrow new NodeOperationError(this.getNode(), 'A non-empty prompt is required.', {\n\t\t\titemIndex: i,\n\t\t});\n\t}\n\tconst options = this.getNodeParameter('options', i, {});\n\tconst jsonOutput = this.getNodeParameter('jsonOutput', i, false) as boolean;\n\tconst maxToolsIterations =\n\t\tnodeVersion >= 1.5 ? (this.getNodeParameter('options.maxToolsIterations', i, 15) as number) : 0;\n\n\tconst abortSignal = this.getExecutionCancelSignal();\n\n\tif (options.maxTokens !== undefined) {\n\t\toptions.max_completion_tokens = options.maxTokens;\n\t\tdelete options.maxTokens;\n\t}\n\n\tif (options.topP !== undefined) {\n\t\toptions.top_p = options.topP;\n\t\tdelete options.topP;","sourceCodeStart":227,"sourceCodeEnd":263,"githubUrl":"https://github.com/n8n-io/n8n/blob/5ac6606e81f67bb9534255570cd4e86fd8101eee/packages/@n8n/nodes-langchain/nodes/vendors/OpenAi/v1/actions/text/message.operation.ts#L227-L263","documentation":"The Text Message operation requires at least one message with non-empty content. After reading the messages array from the parameter, the code checks that at least one message has content that is a non-empty trimmed string. If all messages are empty or contain only whitespace, it throws a NodeOperationError before calling the API.","triggerScenarios":"The messages.values array contains only messages with empty or whitespace-only content strings. The check uses .some() to verify at least one message has content that is a string and .trim() is non-empty. If none pass, the error fires.","commonSituations":"Messages are populated from upstream expressions that resolve to empty; a template/fixedCollection message was added but its text field was left blank; a previous Set node cleared the content field.","solutions":["Ensure at least one message in the messages array has non-empty content text","If messages come from upstream, use an IF node to filter out items with empty message content","Add a fallback expression: {{$json[\"content\"] || 'Hello'}}","Verify the messages.values path is correctly mapped from the upstream data"],"exampleFix":"// before — messages: [{ role: 'user', content: '' }]\n// after  — messages: [{ role: 'user', content: 'Summarize the following text' }]","handlingStrategy":"validation","validationCode":"const messages = this.getNodeParameter('messages.values', i, []) as IDataObject[];\nconst hasNonEmptyContent = messages.some(\n  (m) => typeof m.content === 'string' && m.content.trim() !== ''\n);\nif (!hasNonEmptyContent) {\n  throw new UserError('At least one message must have non-empty content.');\n}","typeGuard":"function hasNonEmptyMessage(messages: IDataObject[]): boolean {\n  return messages.some(m => typeof m.content === 'string' && m.content.trim() !== '');\n}","tryCatchPattern":null,"preventionTips":["Ensure at least one message has non-empty content text","Add fallback expressions for message content from upstream data","Use an IF node to filter items where all message content is empty"],"tags":["openai","text","message","prompt","validation","empty-input","v1"],"backgroundTag":null,"analyzedSha":"5ac6606e81f67bb9534255570cd4e86fd8101eee","analyzedAt":"2026-08-12T05:26:35.080Z","schemaVersion":2},"datasetVersion":"2026-08-12T18:17:37.767Z"}