{"record":{"id":"45c94e3090edccde","repo":"n8n-io/n8n","slug":"a-non-empty-prompt-is-required-45c94e","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/GoogleGemini/actions/text/message.operation.ts","lineNumber":515,"sourceCode":"\t\t\t\ttools.push({\n\t\t\t\t\tfileSearch: {\n\t\t\t\t\t\t...(fileSearchStoreNames && { fileSearchStoreNames }),\n\t\t\t\t\t\t...(metadataFilter && { metadataFilter }),\n\t\t\t\t\t},\n\t\t\t\t});\n\t\t\t}\n\n\t\t\tif (builtInTools.codeExecution) {\n\t\t\t\ttools.push({\n\t\t\t\t\tcodeExecution: {},\n\t\t\t\t});\n\t\t\t}\n\t\t}\n\t}\n\n\tconst nonEmptyMessages = messages.filter((m) => m.content.trim() !== '');\n\tif (!nonEmptyMessages.length) {\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 contents: Content[] = nonEmptyMessages.map((m) => ({\n\t\tparts: [{ text: m.content }],\n\t\trole: m.role,\n\t}));\n\tconst body: GenerateContentRequest = {\n\t\ttools,\n\t\tcontents,\n\t\tgenerationConfig,\n\t\tsystemInstruction: options.systemMessage\n\t\t\t? { parts: [{ text: options.systemMessage }] }\n\t\t\t: undefined,\n\t\t...(toolConfig && { toolConfig }),\n\t};\n\n\tlet response = (await apiRequest.call(this, 'POST', `/v1beta/${model}:generateContent`, {","sourceCodeStart":497,"sourceCodeEnd":533,"githubUrl":"https://github.com/n8n-io/n8n/blob/5ac6606e81f67bb9534255570cd4e86fd8101eee/packages/@n8n/nodes-langchain/nodes/vendors/GoogleGemini/actions/text/message.operation.ts#L497-L533","documentation":"Thrown in the Gemini 'text / message' operation after the assembled messages array is filtered to those whose content.trim() !== ''. If that filter yields zero messages, there is nothing to send to generateContent, so the node refuses the request with itemIndex context.","triggerScenarios":"All chat messages resolved to empty/whitespace-only strings: a Chat Trigger with no user text, a memory/prompt template that produced blank content for every role, an expression referencing a field that is undefined for the current item, or a system message only with no user turn.","commonSituations":"Connected a memory node whose retrieval returned nothing and the prompt template collapsed to empty; referenced $json.missingField in the message content; the trigger payload's text field is genuinely empty for this run.","solutions":["Ensure at least one message role has non-empty content for the item — typically the 'user' message must carry text.","If the content is expression-driven, preview the resolved value and fix the reference (e.g. use $json.message ?? $json.text or a fallback string).","When using memory/templates, confirm the template interpolates a non-empty variable or provides default text.","Filter the input upstream so items with no text don't reach this node."],"exampleFix":"// before — content can resolve to ''\nconst content = $json.userInput;\n\n// after — guarantee non-empty\nconst content = ($json.userInput ?? '').trim() || 'Hello';","handlingStrategy":"validation","validationCode":"const messages = /* …built messages… */;\nconst nonEmpty = messages.filter((m) => m.content.trim() !== '');\nif (nonEmpty.length === 0) {\n  throw new Error('Refusing to call Gemini: no message has non-empty content');\n}","typeGuard":"function hasNonEmptyMessage(messages: { content: string }[]): boolean {\n  return messages.some((m) => m.content.trim() !== '');\n}","tryCatchPattern":null,"preventionTips":["Default every message template to a non-empty fallback string.","Coalesce expression sources: (msg ?? '').trim() || 'Hello'.","Drop items whose prompt resolves to empty before the Gemini node."],"tags":["google-gemini","text-message","prompt","validation","empty-input","node-operation-error"],"backgroundTag":null,"analyzedSha":"5ac6606e81f67bb9534255570cd4e86fd8101eee","analyzedAt":"2026-08-12T05:26:35.080Z","schemaVersion":2},"datasetVersion":"2026-08-12T18:17:37.767Z"}