chroma-core/chroma · error · Error
data.detail
Error message
data.detail
What it means
After POSTing to the Jina embeddings API, the code parses the JSON body and throws new Error(data.detail) whenever the payload has no data array. detail is the FastAPI-style error field Jina returns on failures, so the thrown message is the server's own text (e.g. "Invalid API key"). Note response.ok is never checked: every JSON error response funnels here, while a non-JSON body makes response.json() throw and surfaces as the wrapped error 51 instead.
Source
Thrown at clients/js/packages/chromadb-core/src/embeddings/JinaEmbeddingFunction.ts:123
if (this.embedding_type) {
json_body.embedding_type = this.embedding_type;
}
if (this.normalized) {
json_body.normalized = this.normalized;
}
try {
const response = await fetch(this.api_url, {
method: "POST",
headers: this.headers,
body: JSON.stringify(json_body),
});
const data = (await response.json()) as { data: any[]; detail: string };
if (!data || !data.data) {
throw new Error(data.detail);
}
const embeddings: any[] = data.data;
const sortedEmbeddings = embeddings.sort((a, b) => a.index - b.index);
return sortedEmbeddings.map((result) => result.embedding);
} catch (error) {
if (error instanceof Error) {
throw new Error(`Error calling Jina AI API: ${error.message}`);
} else {
throw new Error(`Error calling Jina AI API: ${error}`);
}
}
}
buildFromConfig(config: StoredConfig): JinaEmbeddingFunction {
return new JinaEmbeddingFunction({
model_name: config.model_name,View on GitHub (pinned to aecdd12c8a)
Solutions
- Read error.message — it IS Jina's detail text and names the actual problem; log it verbatim
- For auth problems, verify the key: curl -s https://api.jina.ai/v1/embeddings -H "Authorization: Bearer $KEY" -H 'Content-Type: application/json' -d '{"model":"jina-embeddings-v3","input":["ping"]}'
- For 429s, reduce batch size/frequency and honor rate limits before resuming
- Check model_name, dimensions, and embedding_type against the current Jina embeddings API docs
Example fix
// before (library code): message is just the server's detail string
throw new Error(data.detail); // e.g. "Invalid API key"
// after (library-level): keep the status context
if (!response.ok || !data?.data) {
throw new Error(`Jina API error ${response.status}: ${data?.detail ?? response.statusText}`);
} Defensive patterns
Strategy: try-catch
Validate before calling
function validateJinaRequest(opts: { apiKey?: string; model: string; texts: string[] }): void {
if (!opts.apiKey) throw new Error("Jina API key missing — check the env var named by api_key_env_var");
if (opts.texts.length === 0) throw new Error("texts must be non-empty");
if (!opts.model.startsWith("jina-")) throw new Error(`Suspicious model name: ${opts.model}`);
}
// run before calling generate(); it prevents the common 401/422 detail errors Try / catch
try {
const vecs = await ef.generate(texts);
} catch (e) {
const msg = e instanceof Error ? e.message : String(e);
if (/API key|auth/i.test(msg)) throw new Error(`Jina auth failed — rotate/check the key`);
if (/rate|quota|429/i.test(msg)) await backoffAndRetry(); // transient
throw e;
} Prevention
- Run a one-token smoke embed at startup to validate key, model and quota before real traffic
- Keep model_name/dimensions/embedding_type in sync with the current Jina API docs
- Log error.message verbatim — for this error it IS the server's detail text
When it happens
Trigger: Jina responds 401/403 (invalid or missing Bearer token), 429 (rate/quota exceeded), or 422 (unsupported model_name/dimensions/embedding_type combination) with a { detail: "..." } body and no data field.
Common situations: Expired, revoked or typo'd Jina key; free-tier quota exhausted mid-job; requesting dimensions on a model without Matryoshka support; wrong model_name string; late_chunking flag unsupported for the account/model.
Related errors
- Failed to generate embeddings: ${response.statusText}
- Jina AI API key is required. Please provide it in the constr
- Error calling Jina AI API: ${error.message}
- Error calling Jina AI API: ${error}
- Invalid response format from Together AI API
AI-assisted analysis of chroma-core/chroma@aecdd12c8a (2026-08-16).
Data as JSON: /api/errors/ea0760ccb8e27f28.
Report an issue: GitHub.