n8n-io/n8n · error · NodeOperationError
Missing search query input at itemIndex ${itemIndex}
Error message
Missing search query input at itemIndex ${itemIndex} What it means
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.
Source
Thrown at packages/@n8n/nodes-langchain/nodes/tools/ToolSerpApi/ToolSerpApi.node.ts:148
},
],
};
async supplyData(this: ISupplyDataFunctions, itemIndex: number): Promise<SupplyData> {
return {
response: logWrapper(await getTool(this, itemIndex), this),
};
}
async execute(this: IExecuteFunctions): Promise<INodeExecutionData[][]> {
const inputData = this.getInputData();
const returnData: INodeExecutionData[] = [];
for (let itemIndex = 0; itemIndex < inputData.length; itemIndex++) {
const tool = await getTool(this, itemIndex);
const item = inputData[itemIndex].json;
if (typeof item.input !== 'string' || !item.input) {
throw new NodeOperationError(
this.getNode(),
`Missing search query input at itemIndex ${itemIndex}`,
);
}
const result = (await tool.invoke(item)) as string;
returnData.push({
json: {
response: result,
},
pairedItem: { item: itemIndex },
});
}
return [returnData];
}
}View on GitHub (pinned to 5ac6606e81)
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.
Example fix
// before: item { json: { q: 'weather' } } → throws
// after:
{ json: { input: 'weather' } } Defensive patterns
Strategy: type-guard
Validate before calling
const q = item.input;
if (typeof q !== 'string' || !q) {
throw new Error(`Item ${itemIndex} is missing a non-empty 'input' string`);
} Type guard
function isSearchQuery(v: unknown): v is string { return typeof v === 'string' && v.length > 0; } Prevention
- 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.
When it happens
Trigger: Input items lacking an 'input' field; input present but empty or non-string; an upstream node emitting items shaped differently than expected.
Common situations: 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.
Related errors
- Input item is missing
- Message exceeds maximum length of ${MAX_AI_BUILDER_PROMPT_LE
- The type ${genericType} is not supported
- The response type must be a string. Received: ${typeof respo
- The response type must be an object or an array of objects
AI-assisted analysis of n8n-io/n8n@5ac6606e81 (2026-08-12).
Data as JSON: /api/errors/618c8339ffb68a11.
Report an issue: GitHub.