{"record":{"id":"a7e94a661800cf58","repo":"n8n-io/n8n","slug":"chromadb-embedding-dimension-mismatch-displayme","errorCode":null,"errorMessage":"ChromaDB embedding dimension mismatch: ${displayMessage}","messagePattern":"ChromaDB embedding dimension mismatch: (.+?)","errorType":"exception","errorClass":"NodeOperationError","httpStatus":null,"severity":"error","filePath":"packages/@n8n/nodes-langchain/nodes/vector_store/VectorStoreChromaDB/VectorStoreChromaDB.node.ts","lineNumber":449,"sourceCode":"\t\t\t\t);\n\t\t\t}\n\t\t}\n\n\t\ttry {\n\t\t\tconst config = await getChromaLibConfig(context, collection, itemIndex);\n\t\t\tawait ExtendedChroma.fromDocuments(documents, embeddings, config);\n\t\t} catch (error) {\n\t\t\tconst chromaError = error as ChromaError;\n\t\t\tconst errorMessage = chromaError.message ?? 'Unknown error';\n\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":431,"sourceCodeEnd":467,"githubUrl":"https://github.com/n8n-io/n8n/blob/5ac6606e81f67bb9534255570cd4e86fd8101eee/packages/@n8n/nodes-langchain/nodes/vector_store/VectorStoreChromaDB/VectorStoreChromaDB.node.ts#L431-L467","documentation":"Thrown as a NodeOperationError (with a remediation `description`) when inserting documents into ChromaDB and the SDK error message or its `response.data.detail` contains `embedding with dimension`. ChromaDB rejects inserts whose embedding vectors do not match the dimension the collection was created with. The display message is the server's detail string, which names the expected and received dimensions.","triggerScenarios":"Collection `my_collection` was created with a 1536-dim model (e.g. OpenAI text-embedding-ada-002) and the user now inserts with a 768-dim model (e.g. MiniLM), or vice versa; embeddings credential was swapped between workflow runs; collection was created by a different workflow with a different model.","commonSituations":"Switching embedding providers mid-project; using the same collection name across workflows that use different models; partial reindex after changing models; dimensions of new multilingual models differing from the legacy ones.","solutions":["Enable the node's `Clear Collection` option so the collection is recreated with the current model's dimension.","Use a new collection name for the new embedding model and leave the old collection in place.","Make the embeddings credential match the model the collection was originally built with.","Confirm the embedding model's output dimension matches before bulk insert (e.g. OpenAI 1536 vs 3072 for v3)."],"exampleFix":"// before\nawait ExtendedChroma.fromDocuments(documents, embeddings, config);\n\n// after: pre-flight check on the first document's vector length against the collection metadata\nconst expectedDim = (await collection.count()) > 0\n  ? (await collection.get({ limit: 1 })).embeddings?.[0]?.length\n  : undefined;\nif (expectedDim && expectedDim !== documents[0]?.metadata?.embeddingLength) {\n  throw new NodeOperationError(context.getNode(),\n    `Embedding dimension mismatch: collection expects ${expectedDim}. Enable Clear Collection or rename.`,\n    { itemIndex });\n}","handlingStrategy":"validation","validationCode":"// Pre-flight: probe the collection's embedding dimension before bulk insert.\nasync function expectedDimension(collection: ChromaCollection): Promise<number | undefined> {\n  const sample = await collection.get({ limit: 1 });\n  return sample.embeddings?.[0]?.length;\n}\n// Compare to embeddings.model.dimension or a one-shot embed of a test string.","typeGuard":"function isDimensionMismatch(error: unknown): boolean {\n  if (!(error instanceof Error)) return false;\n  const detail = (error as { response?: { data?: { detail?: string } } }).response?.data?.detail;\n  return /embedding with dimension/i.test(error.message) || (detail ? /embedding with dimension/i.test(detail) : false);\n}","tryCatchPattern":"try {\n  await ExtendedChroma.fromDocuments(documents, embeddings, config);\n} catch (error) {\n  if (isDimensionMismatch(error)) {\n    throw new NodeOperationError(context.getNode(), `ChromaDB embedding dimension mismatch: ${displayMessage}`, {\n      itemIndex,\n      description: 'Enable Clear Collection or use a different collection name.',\n    });\n  }\n  throw error;\n}","preventionTips":["Use one embedding model per collection name; never mix.","When switching models, enable Clear Collection or pick a new collection name.","Store the model + dimension in the collection metadata for auditability."],"tags":["chromadb","vector-store","embedding-dimension","data-mismatch","node-operation-error","langchain"],"backgroundTag":null,"analyzedSha":"5ac6606e81f67bb9534255570cd4e86fd8101eee","analyzedAt":"2026-08-12T05:26:35.080Z","schemaVersion":2},"datasetVersion":"2026-08-13T14:17:21.547Z"}