{"record":{"id":"96f3d58f356892f9","repo":"n8n-io/n8n","slug":"the-prompt-parameter-is-empty-96f3d5","errorCode":null,"errorMessage":"The 'prompt' parameter is empty.","messagePattern":"The 'prompt' parameter is empty\\.","errorType":"exception","errorClass":"NodeOperationError","httpStatus":null,"severity":"error","filePath":"packages/@n8n/nodes-langchain/nodes/chains/ChainLLM/methods/processItem.ts","lineNumber":65,"sourceCode":"\tconst outputParser = await getOptionalOutputParser(ctx, itemIndex);\n\n\t// Get user prompt based on node version\n\tlet prompt: string;\n\n\tif (ctx.getNode().typeVersion <= 1.3) {\n\t\tprompt = ctx.getNodeParameter('prompt', itemIndex) as string;\n\t} else {\n\t\tprompt = getPromptInputByType({\n\t\t\tctx,\n\t\t\ti: itemIndex,\n\t\t\tinputKey: 'text',\n\t\t\tpromptTypeKey: 'promptType',\n\t\t});\n\t}\n\n\t// Validate prompt\n\tif (prompt === undefined) {\n\t\tthrow new NodeOperationError(ctx.getNode(), \"The 'prompt' parameter is empty.\");\n\t}\n\n\t// Get chat messages if configured\n\tconst messages = ctx.getNodeParameter(\n\t\t'messages.messageValues',\n\t\titemIndex,\n\t\t[],\n\t) as MessageTemplate[];\n\n\t// Execute the chain\n\treturn await executeChain({\n\t\tcontext: ctx,\n\t\titemIndex,\n\t\tquery: prompt,\n\t\tllm,\n\t\toutputParser,\n\t\tmessages,\n\t\tfallbackLlm,","sourceCodeStart":47,"sourceCodeEnd":83,"githubUrl":"https://github.com/n8n-io/n8n/blob/5ac6606e81f67bb9534255570cd4e86fd8101eee/packages/@n8n/nodes-langchain/nodes/chains/ChainLLM/methods/processItem.ts#L47-L83","documentation":"Thrown by processItem in the Basic LLM Chain when the resolved 'prompt' value is undefined. For typeVersion <= 1.3 the prompt is read directly from the 'prompt' parameter; for newer versions it is resolved through getPromptInputByType. If either yields undefined, the chain has nothing to send to the LLM.","triggerScenarios":"The prompt parameter (or the expression backing the 'text' prompt input) evaluates to undefined for the current itemIndex. Common with expression-based prompts that reference a missing JSON field.","commonSituations":"The prompt expression references {{$json.field}} but field does not exist on the input item; the user left the prompt field blank; the prompt source was switched (e.g. from 'text' to 'definition') but no value supplied; upstream node changed its output shape.","solutions":["Open the Basic LLM Chain and verify the prompt parameter/expression resolves to a non-empty string for every input item.","Use a fallback in the expression, e.g. {{$json.prompt || 'Summarize the following:'}}.","Inspect the failing itemIndex in the execution data to see which field is missing.","If using promptType other than 'text', confirm the prompt source value is provided."],"exampleFix":"// before\nif (prompt === undefined) {\n  throw new NodeOperationError(ctx.getNode(), \"The 'prompt' parameter is empty.\");\n}\n\n// after — also reject empty strings and surface itemIndex\nif (!prompt?.trim()) {\n  throw new NodeOperationError(ctx.getNode(), {\n    message: \"The 'prompt' parameter is empty.\",\n    itemIndex,\n  });\n}","handlingStrategy":"validation","validationCode":"let prompt: string;\nif (ctx.getNode().typeVersion <= 1.3) {\n  prompt = ctx.getNodeParameter('prompt', itemIndex) as string;\n} else {\n  prompt = getPromptInputByType({ ctx, i: itemIndex, inputKey: 'text', promptTypeKey: 'promptType' });\n}\nif (!prompt?.trim()) {\n  throw new Error(`Prompt is empty for item ${itemIndex}`);\n}","typeGuard":"function isNonEmptyString(v: unknown): v is string {\n  return typeof v === 'string' && v.trim().length > 0;\n}","tryCatchPattern":null,"preventionTips":["Always provide a fallback in the prompt expression: {{$json.prompt || 'default text'}}.","Filter items with empty prompts upstream.","Test expressions against sample data before deploying."],"tags":["configuration","parameter-validation","prompt","per-item"],"backgroundTag":null,"analyzedSha":"5ac6606e81f67bb9534255570cd4e86fd8101eee","analyzedAt":"2026-08-12T05:26:35.080Z","schemaVersion":2},"datasetVersion":"2026-08-12T18:17:37.767Z"}