{"record":{"id":"bd64e2f66a0b1fce","repo":"n8n-io/n8n","slug":"single-document-per-item-expected","errorCode":null,"errorMessage":"Single document per item expected","messagePattern":"Single document per item expected","errorType":"validation","errorClass":"NodeOperationError","httpStatus":null,"severity":"error","filePath":"packages/@n8n/ai-utilities/src/utils/vector-store/createVectorStoreNode/operations/updateOperation.ts","lineNumber":58,"sourceCode":"\t\t// Get the document ID to update\n\t\tconst documentId = context.getNodeParameter('id', itemIndex, '', {\n\t\t\textractValue: true,\n\t\t}) as string;\n\n\t\t// Get the vector store client\n\t\tconst vectorStore = await args.getVectorStoreClient(context, undefined, embeddings, itemIndex);\n\n\t\ttry {\n\t\t\t// Process the document from the input\n\t\t\tconst { processedDocuments, serializedDocuments } = await processDocument(\n\t\t\t\tloader,\n\t\t\t\titemData,\n\t\t\t\titemIndex,\n\t\t\t);\n\n\t\t\t// Validate that we have exactly one document to update\n\t\t\tif (processedDocuments?.length !== 1) {\n\t\t\t\tthrow new NodeOperationError(context.getNode(), 'Single document per item expected');\n\t\t\t}\n\n\t\t\t// Add the serialized document to the result\n\t\t\tresultData.push(...serializedDocuments);\n\n\t\t\t// Use document ID to update the existing document\n\t\t\tawait vectorStore.addDocuments(processedDocuments, {\n\t\t\t\tids: [documentId],\n\t\t\t});\n\n\t\t\t// Log the AI event for analytics\n\t\t\tlogAiEvent(context, 'ai-vector-store-updated');\n\t\t} finally {\n\t\t\t// Release the vector store client if a release method was provided\n\t\t\targs.releaseVectorStoreClient?.(vectorStore);\n\t\t}\n\t}\n","sourceCodeStart":40,"sourceCodeEnd":76,"githubUrl":"https://github.com/n8n-io/n8n/blob/5ac6606e81f67bb9534255570cd4e86fd8101eee/packages/@n8n/ai-utilities/src/utils/vector-store/createVectorStoreNode/operations/updateOperation.ts#L40-L76","documentation":"Cardinality-validation error in handleUpdateOperation, raised as NodeOperationError. Update replaces one existing document by ID, so it fires when document processing produced zero or multiple documents for the item instead of exactly one. The count check runs after processDocument, before the store client is asked to update.","triggerScenarios":"Thrown at packages/@n8n/ai-utilities/src/utils/vector-store/createVectorStoreNode/operations/updateOperation.ts:58 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Ensure each input item resolves to exactly one document when the update operation runs.","Split or flatten input items so one document is produced per item.","Check the loader configuration: loading a binary file that yields multiple chunks violates the one-document requirement."],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"5ac6606e81f67bb9534255570cd4e86fd8101eee","analyzedAt":"2026-08-12T05:26:35.080Z","contentChangedAt":"2026-08-12T05:26:35.080Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}