n8n-io/n8n · error · NodeOperationError
ChromaDB embedding dimension mismatch: ${displayMessage}
Error message
ChromaDB embedding dimension mismatch: ${displayMessage} What it means
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.
Source
Thrown at packages/@n8n/nodes-langchain/nodes/vector_store/VectorStoreChromaDB/VectorStoreChromaDB.node.ts:449
);
}
}
try {
const config = await getChromaLibConfig(context, collection, itemIndex);
await ExtendedChroma.fromDocuments(documents, embeddings, config);
} catch (error) {
const chromaError = error as ChromaError;
const errorMessage = chromaError.message ?? 'Unknown error';
const detailMessage = chromaError.response?.data?.detail;
// Handle dimension mismatch error specifically
if (
errorMessage.includes('embedding with dimension') ||
detailMessage?.includes('embedding with dimension')
) {
const displayMessage = detailMessage ?? errorMessage;
throw new NodeOperationError(
context.getNode(),
`ChromaDB embedding dimension mismatch: ${displayMessage}`,
{
itemIndex,
description:
'The collection expects embeddings with different dimensions. Enable "Clear Collection" option to recreate the collection with correct dimensions, or use a different collection name.',
},
);
}
throw new NodeOperationError(
context.getNode(),
`Error inserting documents into ChromaDB: ${errorMessage}`,
{ itemIndex },
);
}
},
}) {}
View on GitHub (pinned to 5ac6606e81)
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).
Example fix
// before
await ExtendedChroma.fromDocuments(documents, embeddings, config);
// after: pre-flight check on the first document's vector length against the collection metadata
const expectedDim = (await collection.count()) > 0
? (await collection.get({ limit: 1 })).embeddings?.[0]?.length
: undefined;
if (expectedDim && expectedDim !== documents[0]?.metadata?.embeddingLength) {
throw new NodeOperationError(context.getNode(),
`Embedding dimension mismatch: collection expects ${expectedDim}. Enable Clear Collection or rename.`,
{ itemIndex });
} Defensive patterns
Strategy: validation
Validate before calling
// Pre-flight: probe the collection's embedding dimension before bulk insert.
async function expectedDimension(collection: ChromaCollection): Promise<number | undefined> {
const sample = await collection.get({ limit: 1 });
return sample.embeddings?.[0]?.length;
}
// Compare to embeddings.model.dimension or a one-shot embed of a test string. Type guard
function isDimensionMismatch(error: unknown): boolean {
if (!(error instanceof Error)) return false;
const detail = (error as { response?: { data?: { detail?: string } } }).response?.data?.detail;
return /embedding with dimension/i.test(error.message) || (detail ? /embedding with dimension/i.test(detail) : false);
} Try / catch
try {
await ExtendedChroma.fromDocuments(documents, embeddings, config);
} catch (error) {
if (isDimensionMismatch(error)) {
throw new NodeOperationError(context.getNode(), `ChromaDB embedding dimension mismatch: ${displayMessage}`, {
itemIndex,
description: 'Enable Clear Collection or use a different collection name.',
});
}
throw error;
} Prevention
- 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.
When it happens
Trigger: 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.
Common situations: 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.
Related errors
- Collection must be a string
- Error connecting to ChromaDB: ${message}
- Error inserting documents into ChromaDB: ${errorMessage}
- Failed to initialize Chroma collection
- Cannot connect to ChromaDB. Please ensure ChromaDB is runnin
AI-assisted analysis of n8n-io/n8n@5ac6606e81 (2026-08-12).
Data as JSON: /api/errors/a7e94a661800cf58.
Report an issue: GitHub.