janhq/jan · error · Error
Embedding dimension not available
Error message
Embedding dimension not available
What it means
Thrown by VectorDBExtension.ingestFileForProject() after re-embedding chunks when the resulting embedding vectors have length 0 (finalDimension <= 0). This means the embedding engine returned empty/malformed vectors even though chunks exist. It surfaces an upstream embed() failure that did not throw but produced no usable vector data.
Source
Thrown at extensions/vector-db-extension/src/index.ts:118
const collectionDimension = dimension > 0 ? dimension : 384
await this.createCollectionForProject(projectId, collectionDimension)
// Now check for duplicates
const existingFiles = await vecdb.listAttachments(this.collectionForProject(projectId)).catch(() => [])
const duplicate = existingFiles.find((f: any) => f.name === file.name && f.path === file.path)
if (duplicate) {
throw new Error(`File '${file.name}' has already been attached to this project`)
}
if (!chunks.length) {
const fi = await vecdb.createFile(this.collectionForProject(projectId), file)
return fi
}
// Re-embed if we got dimension from createCollection
const embeddings = await this.embedTexts(chunks)
const finalDimension = embeddings[0]?.length || 0
if (finalDimension <= 0) throw new Error('Embedding dimension not available')
// Ensure collection has correct dimension
if (finalDimension !== collectionDimension) {
await this.deleteCollectionForProject(projectId)
await this.createCollectionForProject(projectId, finalDimension)
}
const fi = await vecdb.createFile(this.collectionForProject(projectId), file)
await vecdb.insertChunks(
this.collectionForProject(projectId),
fi.id,
chunks.map((t, i) => ({ text: t, embedding: embeddings[i] }))
)
const infos = await vecdb.listAttachments(this.collectionForProject(projectId))
const updated = infos.find((e) => e.id === fi.id)
return updated || { ...fi, chunk_count: chunks.length }
}
View on GitHub (pinned to fad3f12a14)
Solutions
- Verify an embedding model is fully loaded and embed() returns vectors (test embedTexts on a sample).
- Restart/reload the llamacpp extension and embedding model.
- Reinstall or pick a different embedding model whose output dimension is non-zero.
- Inspect llamacpp logs for the embed() call to see why vectors are empty.
Example fix
// before
await vecdbExt.ingestFileForProject(projectId, file, opts)
// after
const probe = await vecdbExt.embedTexts?.(['probe']) ?? await rag.embed(['probe'])
if (!probe?.[0]?.length) {
throw new Error('Embedding model returned no vectors; reload the embedding model')
}
await vecdbExt.ingestFileForProject(projectId, file, opts) Defensive patterns
Strategy: try-catch
Validate before calling
const probe = await rag.embed(['dimension probe']).catch(() => [])
if (!probe?.[0]?.length) {
// embedding model not ready; do not ingest
} Try / catch
try {
await vecdbExt.ingestFileForProject(projectId, file, opts)
} catch (e) {
if (e instanceof Error && e.message === 'Embedding dimension not available') {
await reloadEmbeddingModel()
return vecdbExt.ingestFileForProject(projectId, file, opts)
}
throw e
} Prevention
- Probe embed() on a sample before bulk ingestion.
- Ensure the embedding model is fully loaded.
- Reload the embedding model if vectors come back empty.
When it happens
Trigger: Embedding model loaded but returning empty vectors; embed() resolves with an empty/short data array so embeddings[0]?.length is 0; embedding dimensionality could not be derived from the response shape.
Common situations: Embedding model partially loaded or corrupted; llamacpp embed() returned an error object treated as data; mismatch between requested text count and returned indices.
Related errors
- Vector DB extension does not support project-level ingestion
- File '${file.name}' has already been attached to this projec
- Failed to determine embedding context size: ${e instanceof E
- Failed to count embedding tokens: ${e instanceof Error ? e.m
- llamacpp extension not available
AI-assisted analysis of janhq/jan@fad3f12a14 (2026-08-12).
Data as JSON: /api/errors/74fca0024b1793a8.
Report an issue: GitHub.