{"record":{"id":"618c8339ffb68a11","repo":"n8n-io/n8n","slug":"missing-search-query-input-at-itemindex-iteminde","errorCode":null,"errorMessage":"Missing search query input at itemIndex ${itemIndex}","messagePattern":"Missing search query input at itemIndex (.+?)","errorType":"exception","errorClass":"NodeOperationError","httpStatus":null,"severity":"error","filePath":"packages/@n8n/nodes-langchain/nodes/tools/ToolSerpApi/ToolSerpApi.node.ts","lineNumber":148,"sourceCode":"\t\t\t},\n\t\t],\n\t};\n\n\tasync supplyData(this: ISupplyDataFunctions, itemIndex: number): Promise<SupplyData> {\n\t\treturn {\n\t\t\tresponse: logWrapper(await getTool(this, itemIndex), this),\n\t\t};\n\t}\n\n\tasync execute(this: IExecuteFunctions): Promise<INodeExecutionData[][]> {\n\t\tconst inputData = this.getInputData();\n\t\tconst returnData: INodeExecutionData[] = [];\n\t\tfor (let itemIndex = 0; itemIndex < inputData.length; itemIndex++) {\n\t\t\tconst tool = await getTool(this, itemIndex);\n\t\t\tconst item = inputData[itemIndex].json;\n\n\t\t\tif (typeof item.input !== 'string' || !item.input) {\n\t\t\t\tthrow new NodeOperationError(\n\t\t\t\t\tthis.getNode(),\n\t\t\t\t\t`Missing search query input at itemIndex ${itemIndex}`,\n\t\t\t\t);\n\t\t\t}\n\n\t\t\tconst result = (await tool.invoke(item)) as string;\n\n\t\t\treturnData.push({\n\t\t\t\tjson: {\n\t\t\t\t\tresponse: result,\n\t\t\t\t},\n\t\t\t\tpairedItem: { item: itemIndex },\n\t\t\t});\n\t\t}\n\n\t\treturn [returnData];\n\t}\n}","sourceCodeStart":130,"sourceCodeEnd":166,"githubUrl":"https://github.com/n8n-io/n8n/blob/5ac6606e81f67bb9534255570cd4e86fd8101eee/packages/@n8n/nodes-langchain/nodes/tools/ToolSerpApi/ToolSerpApi.node.ts#L130-L166","documentation":"Thrown by the deprecated SerpApi tool's execute() when item.input is not a non-empty string. Identical contract to other search tools: a search query string must be supplied per input item.","triggerScenarios":"Input items lacking an 'input' field; input present but empty or non-string; an upstream node emitting items shaped differently than expected.","commonSituations":"This node is deprecated (the description says so), so a stale workflow referencing it may have drifted from its input contract; field-name mismatches after refactoring upstream nodes.","solutions":["Map the upstream query field to 'input' for every item.","Add a Set/Edit Fields node to guarantee a non-empty 'input' string.","Migrate to the official verified community SerpApi node (the node description recommends this).","Drop empty items before they reach the tool."],"exampleFix":"// before: item { json: { q: 'weather' } } → throws\n// after:\n{ json: { input: 'weather' } }","handlingStrategy":"type-guard","validationCode":"const q = item.input;\nif (typeof q !== 'string' || !q) {\n  throw new Error(`Item ${itemIndex} is missing a non-empty 'input' string`);\n}","typeGuard":"function isSearchQuery(v: unknown): v is string { return typeof v === 'string' && v.length > 0; }","tryCatchPattern":null,"preventionTips":["Map upstream query fields to 'input' before the SerpApi node.","Migrate to the official verified community SerpApi node.","Validate input items in a Code node upstream."],"tags":["serpapi","ai-tool","input-validation","deprecated","search"],"backgroundTag":null,"analyzedSha":"5ac6606e81f67bb9534255570cd4e86fd8101eee","analyzedAt":"2026-08-12T05:26:35.080Z","schemaVersion":2},"datasetVersion":"2026-08-12T18:17:37.767Z"}