vxcontrol/pentagi · error
knowledge: compute embedding: %w
Error message
knowledge: compute embedding: %w
What it means
CreateDocument computes an embedding for the new document content (truncated to maxEmbeddingBytes) before insertion. Failure of embedder.EmbedDocuments — nil embedder, provider auth/network errors — is wrapped as 'knowledge: compute embedding'.
Source
Thrown at backend/pkg/database/knowledge/knowledge.go:497
if input.AnswerType != nil {
meta.AnswerType = string(*input.AnswerType)
}
if input.CodeLang != nil {
meta.CodeLang = *input.CodeLang
}
content := strings.TrimSpace(input.Content)
meta.PartSize = len(content)
meta.TotalSize = len(content)
// Truncate to embedding size limit for vector computation; full content goes to DB.
embeddingText := content
if len(embeddingText) > ks.maxEmbeddingBytes {
embeddingText = embeddingText[:ks.maxEmbeddingBytes]
}
vecs, err := ks.embedder.EmbedDocuments(ctx, []string{embeddingText})
if err != nil {
return nil, fmt.Errorf("knowledge: compute embedding: %w", err)
}
if len(vecs) == 0 {
return nil, fmt.Errorf("knowledge: embedder returned no vectors")
}
cmJSON, err := metaToJSON(meta)
if err != nil {
return nil, fmt.Errorf("knowledge: marshal cmetadata: %w", err)
}
id := uuid.New()
docID, err := ks.db.InsertKnowledgeDocument(ctx, database.InsertKnowledgeDocumentParams{
Uuid: id,
Document: nsOf(content),
Embedding: formatVector(vecs[0]),
Cmetadata: cmJSON.RawMessage,
})
if err != nil {View on GitHub (pinned to ea665308ba)
Solutions
- If the wrapped error says the embedder is not configured, set the embedding provider env vars and restart.
- Validate provider credentials with a direct API call to the embeddings endpoint.
- Check network reachability from the backend to the provider (DNS, proxy, ollama service name).
- For 429/timeout causes, retry with backoff; for bulk imports, throttle creation rate.
Example fix
// before
vecs, err := ks.embedder.EmbedDocuments(ctx, []string{embeddingText})
// after
if ks.embedder == nil {
return nil, fmt.Errorf("knowledge: embedding provider not configured; set embedding env vars")
}
vecs, err := ks.embedder.EmbedDocuments(ctx, []string{embeddingText}) Defensive patterns
Strategy: validation
Validate before calling
if embedder == nil {
return errors.New("embedding provider not configured")
}
if strings.TrimSpace(content) == "" {
return errors.New("document content must not be empty")
}
if len(content) > maxEmbeddingBytes*100 { // absurd input guard
return errors.New("document content too large")
} Type guard
func isEmbedderConfigErr(err error) bool {
return strings.Contains(err.Error(), "not configured")
} Try / catch
doc, err := store.CreateDocument(ctx, userID, input)
if err != nil {
if strings.Contains(err.Error(), "compute embedding") {
// check provider status/key before surfacing to user
return fmt.Errorf("document indexing temporarily unavailable: %w", err)
}
return err
} Prevention
- Configure at least one embedding provider in every environment.
- Check provider quota/limits before bulk document imports.
- Truncate content to maxEmbeddingBytes client-side to keep costs predictable.
- Alert on embedding API error rates.
When it happens
Trigger: CreateDocument called when no embedding provider is configured, the provider API key is wrong/expired, the endpoint is unreachable, or the request is rate-limited.
Common situations: Deploying without embedding env vars (nil embedder by design); Ollama not running in the compose network; provider outage or 429 under bulk document creation.
Related errors
- knowledge: embed query: %w
- knowledge: embedding provider is not configured
- failed to load document: %w
- token validation disabled with default salt
- Token.CreationDisabled
AI-assisted analysis of vxcontrol/pentagi@ea665308ba (2026-09-01).
Data as JSON: /api/errors/50cfae61685f083d.
Report an issue: GitHub.