chroma-core/chroma · error · Error
Error calling Jina AI API: ${error}
Error message
Error calling Jina AI API: ${error} What it means
The rarely-taken else branch of the same catch: it fires only when the caught value is not an Error instance — e.g. a rejected promise carrying a plain string, number, or custom object from somewhere in the Jina request path. In practice almost all Node fetch/JSON failures are Errors, so this is essentially a formatting fallback that stringifies whatever was thrown.
Source
Thrown at clients/js/packages/chromadb-core/src/embeddings/JinaEmbeddingFunction.ts:134
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,
api_key_env_var: config.api_key_env_var,
task: config.task,
late_chunking: config.late_chunking,
truncate: config.truncate,
dimensions: config.dimensions,
embedding_type: config.embedding_type,
normalized: config.normalized,
});
}
getConfig(): StoredConfig {View on GitHub (pinned to aecdd12c8a)
Solutions
- Log the raw value — the template stringifies it, so printing the error reveals the thrower
- Search the dependency chain for non-Error throw sites (throw "..." or reject("...") ) and fix or shim them to throw proper Errors
- Update/replace the offending package if it comes from a third-party dependency
Defensive patterns
Strategy: try-catch
Try / catch
try {
const vecs = await ef.generate(texts);
} catch (e) {
const msg = e instanceof Error ? e.message : String(e); // normalize non-Error throwables
if (msg.startsWith("Error calling Jina AI API:")) {
// inspect the suffix; a stringified non-Error usually points at a mock or shim
}
throw e;
} Prevention
- Enable @typescript-eslint/only-throw-error so your own code never throws non-Error values
- Reject with Error objects in test doubles/mocks, not plain strings
- Upgrade third-party shims that reject with non-Error values
When it happens
Trigger: A dependency, runtime shim, or test double inside the request path rejecting with a non-Error value (throw "string", Promise.reject(42), custom object without Error prototype).
Common situations: Exotic runtimes/bundlers that alter rejection shapes; unit tests with mocks rejecting strings; essentially never seen in normal Node usage.
Related errors
- Error calling Cloudflare Workers AI API: ${error}
- Error calling Jina AI API: ${error.message}
- Error calling Cloudflare Workers AI API: ${error.message}
- Jina AI API key is required. Please provide it in the constr
- data.detail
AI-assisted analysis of chroma-core/chroma@aecdd12c8a (2026-08-16).
Data as JSON: /api/errors/9dadc7516ff0c6df.
Report an issue: GitHub.