{"record":{"id":"32e087e4dabfbbe9","repo":"n8n-io/n8n","slug":"error-inserting-documents-into-chromadb-errorme","errorCode":null,"errorMessage":"Error inserting documents into ChromaDB: ${errorMessage}","messagePattern":"Error inserting documents into ChromaDB: (.+?)","errorType":"exception","errorClass":"NodeOperationError","httpStatus":null,"severity":"error","filePath":"packages/@n8n/nodes-langchain/nodes/vector_store/VectorStoreChromaDB/VectorStoreChromaDB.node.ts","lineNumber":459,"sourceCode":"\t\t\tconst detailMessage = chromaError.response?.data?.detail;\n\n\t\t\t// Handle dimension mismatch error specifically\n\t\t\tif (\n\t\t\t\terrorMessage.includes('embedding with dimension') ||\n\t\t\t\tdetailMessage?.includes('embedding with dimension')\n\t\t\t) {\n\t\t\t\tconst displayMessage = detailMessage ?? errorMessage;\n\t\t\t\tthrow new NodeOperationError(\n\t\t\t\t\tcontext.getNode(),\n\t\t\t\t\t`ChromaDB embedding dimension mismatch: ${displayMessage}`,\n\t\t\t\t\t{\n\t\t\t\t\t\titemIndex,\n\t\t\t\t\t\tdescription:\n\t\t\t\t\t\t\t'The collection expects embeddings with different dimensions. Enable \"Clear Collection\" option to recreate the collection with correct dimensions, or use a different collection name.',\n\t\t\t\t\t},\n\t\t\t\t);\n\t\t\t}\n\t\t\tthrow new NodeOperationError(\n\t\t\t\tcontext.getNode(),\n\t\t\t\t`Error inserting documents into ChromaDB: ${errorMessage}`,\n\t\t\t\t{ itemIndex },\n\t\t\t);\n\t\t}\n\t},\n}) {}\n","sourceCodeStart":441,"sourceCodeEnd":467,"githubUrl":"https://github.com/n8n-io/n8n/blob/5ac6606e81f67bb9534255570cd4e86fd8101eee/packages/@n8n/nodes-langchain/nodes/vector_store/VectorStoreChromaDB/VectorStoreChromaDB.node.ts#L441-L467","documentation":"Catch-all NodeOperationError in `populateVectorStore` for any insert failure that is NOT the dimension-mismatch case. The original Chroma SDK error message is appended. Wraps `ExtendedChroma.fromDocuments`, which is what actually adds vectors to the collection.","triggerScenarios":"Insert failures other than dimension mismatch: server-side 5xx during indexing, payload too large, network reset mid-batch, invalid document IDs, metadata schema violation, rate limit from Chroma Cloud.","commonSituations":"Bulk inserting thousands of documents and hitting a timeout; Chroma Cloud rate limit; metadata value of an unsupported type (e.g. nested object); SSL handshake to a self-hosted instance failing intermittently.","solutions":["Read the appended `errorMessage` to identify the server-side cause.","Reduce batch size or insert in smaller chunks to avoid payload/timeout limits.","Flatten metadata values to primitives before insert (ChromaDB rejects nested objects in some versions).","Retry on transient 5xx; if persistent, check ChromaDB server logs and version compatibility."],"exampleFix":"// before\nthrow new NodeOperationError(\n  context.getNode(),\n  `Error inserting documents into ChromaDB: ${errorMessage}`,\n  { itemIndex },\n);\n\n// after: hint at the two most common non-dimension causes\nconst isPayload = /payload|too large|413/i.test(errorMessage);\nthrow new NodeOperationError(\n  context.getNode(),\n  `Error inserting documents into ChromaDB: ${errorMessage}`,\n  {\n    itemIndex,\n    description: isPayload\n      ? 'Reduce the batch size or document size and retry.'\n      : 'Check the ChromaDB server logs and metadata shapes.',\n  },\n);","handlingStrategy":"try-catch","validationCode":"// Pre-flight: validate document shape (metadata primitives, non-empty pageContent) before insert.\nfunction validateDocuments(docs: Document[]): void {\n  for (const d of docs) {\n    if (typeof d.pageContent !== 'string' || d.pageContent.length === 0) {\n      throw new Error('Each document must have non-empty string pageContent');\n    }\n    for (const [k, v] of Object.entries(d.metadata ?? {})) {\n      if (v !== null && typeof v === 'object') {\n        throw new Error(`Metadata '${k}' must be a primitive, got ${typeof v}`);\n      }\n    }\n  }\n}","typeGuard":"function isPayloadError(error: unknown): boolean {\n  return error instanceof Error && /payload|too large|413/i.test(error.message);\n}","tryCatchPattern":"try {\n  await ExtendedChroma.fromDocuments(documents, embeddings, config);\n} catch (error) {\n  const msg = error instanceof Error ? error.message : 'Unknown error';\n  throw new NodeOperationError(context.getNode(), `Error inserting documents into ChromaDB: ${msg}`, {\n    itemIndex,\n    description: isPayloadError(error) ? 'Reduce batch size.' : 'Check ChromaDB logs and metadata shapes.',\n  });\n}","preventionTips":["Batch inserts to a few hundred documents per call to stay under payload limits.","Flatten metadata to primitives before insert.","Retry transient 5xx once before changing config."],"tags":["chromadb","vector-store","catch-all","insert","node-operation-error","langchain"],"backgroundTag":null,"analyzedSha":"5ac6606e81f67bb9534255570cd4e86fd8101eee","analyzedAt":"2026-08-12T05:26:35.080Z","schemaVersion":2},"datasetVersion":"2026-08-12T13:17:24.610Z"}