n8n-io/n8n · error · NodeOperationError
Invalid document at index
Error message
Invalid document at index ${invalidIndex} What it means
Generic input-validation error from validateEmbedDocumentsInput, wrapped as NodeOperationError with the node for context. It fires when a document entry in the documents array is undefined, null, or an empty string — an unusable item for embedding. The array itself was valid; one indexed item was not.
Solutions
- Ensure every element of the documents array is a non-empty string before calling validateEmbedDocumentsInput.
- Filter out null, undefined, and empty-string entries upstream, or fix the upstream node so it emits valid text for each item.
- Check the input data mapping: a missing field or empty expression result commonly produces null/empty entries at some index.
Defensive patterns
Strategy: validation
When it happens
Trigger: Thrown at packages/@n8n/ai-utilities/src/utils/embeddings-input-validation.ts:44 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of n8n-io/n8n@5ac6606e81 (2026-08-12).
Data as JSON: /api/errors/b7b9458ef321011d.
Report an issue: GitHub.
Appendix: source
Thrown at packages/@n8n/ai-utilities/src/utils/embeddings-input-validation.ts:44
*
* @param documents - The documents array to validate
* @param node - The node for error context
* @returns The validated documents array
* @throws NodeOperationError if documents is not an array or contains invalid entries
*/
export function validateEmbedDocumentsInput(documents: unknown, node: INode): string[] {
if (!Array.isArray(documents)) {
throw new NodeOperationError(node, 'Documents must be an array', {
description: 'Expected an array of strings to embed.',
});
}
const invalidIndex = documents.findIndex(
(doc) => doc === undefined || doc === null || doc === '',
);
if (invalidIndex !== -1) {
throw new NodeOperationError(node, `Invalid document at index ${invalidIndex}`, {
description: `Document at index ${invalidIndex} is empty or undefined. All documents must be non-empty strings.`,
});
}
return documents;
}
View on GitHub (pinned to 5ac6606e81)