{"record":{"id":"ebe914964dd3812e","repo":"n8n-io/n8n","slug":"a-non-empty-prompt-is-required-ebe914","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/helpers/baseAnalyze.ts","lineNumber":22,"sourceCode":"\ttype IExecuteFunctions,\n\ttype INodeExecutionData,\n} from 'n8n-workflow';\n\nimport type { Content, GenerateContentResponse } from './interfaces';\nimport { downloadFile, uploadFile } from './utils';\nimport { apiRequest } from '../transport';\n\nexport async function baseAnalyze(\n\tthis: IExecuteFunctions,\n\ti: number,\n\turlsPropertyName: string,\n\tfallbackMimeType: string,\n): Promise<INodeExecutionData[]> {\n\tconst model = this.getNodeParameter('modelId', i, '', { extractValue: true }) as string;\n\tconst inputType = this.getNodeParameter('inputType', i, 'url') as string;\n\tconst text = this.getNodeParameter('text', i, '') as string;\n\tif (!text.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 simplify = this.getNodeParameter('simplify', i, true) as boolean;\n\tconst options = this.getNodeParameter('options', i, {});\n\tvalidateNodeParameters(\n\t\toptions,\n\t\t{ maxOutputTokens: { type: 'number', required: false } },\n\t\tthis.getNode(),\n\t);\n\tconst generationConfig = {\n\t\tmaxOutputTokens: options.maxOutputTokens,\n\t};\n\n\tlet contents: Content[];\n\tif (inputType === 'url') {\n\t\tconst urls = this.getNodeParameter(urlsPropertyName, i, '') as string;\n\t\tconst filesDataPromises = urls","sourceCodeStart":4,"sourceCodeEnd":40,"githubUrl":"https://github.com/n8n-io/n8n/blob/5ac6606e81f67bb9534255570cd4e86fd8101eee/packages/@n8n/nodes-langchain/nodes/vendors/GoogleGemini/helpers/baseAnalyze.ts#L4-L40","documentation":"Prompt guard in the shared baseAnalyze helper used by Gemini document/audio analysis. Reads the 'text' parameter; if it trims to empty, throws before building the generationConfig or calling the API. Same contract as the other Gemini prompt guards.","triggerScenarios":"The 'text' (prompt/instruction) field is empty or whitespace for the current item, or its expression resolved to undefined (e.g. $json.question where the upstream field is missing).","commonSituations":"Analyzing a document/audio but the instruction text wasn't filled; an expression pointed at the wrong field; a Set node upstream dropped the field.","solutions":["Provide a non-empty instruction in the 'text' field, or fix the expression (e.g. ($json.instruction ?? '').trim() || 'Summarize this').","Ensure the upstream node emits the referenced field for every item.","Filter out items lacking an instruction before this node."],"exampleFix":"// before\nconst text = '';\n\n// after\nconst text = 'Extract the key entities from this document.';","handlingStrategy":"validation","validationCode":"const text = String(this.getNodeParameter('text', i, '')).trim();\nif (!text) {\n  throw new Error('Analyze requires a non-empty instruction text');\n}","typeGuard":"function isNonEmptyInstruction(t: unknown): t is string {\n  return typeof t === 'string' && t.trim().length > 0;\n}","tryCatchPattern":null,"preventionTips":["Default the instruction field to a sensible prompt.","Coalesce expression sources: ($json.instruction ?? '').trim() || 'Summarize this'.","Filter empty-instruction items upstream."],"tags":["google-gemini","analyze","prompt","validation","empty-input","node-operation-error"],"backgroundTag":null,"analyzedSha":"5ac6606e81f67bb9534255570cd4e86fd8101eee","analyzedAt":"2026-08-12T05:26:35.080Z","schemaVersion":2},"datasetVersion":"2026-08-13T19:17:28.613Z"}