chroma-core/chroma · error · Error
resp.detail || "Unknown error"
Error message
resp.detail || "Unknown error"
What it means
In CloudflareWorkersAIEmbeddingFunction.generate, after POSTing to the Workers AI endpoint the code parses the response as JSON and requires resp.result.data to exist. If the payload lacks that shape (typical for Cloudflare error bodies, which carry a detail field), it throws new Error(resp.detail || 'Unknown error'). Because this throw sits inside the surrounding try block, it is immediately re-wrapped, so callers normally see it as 'Error calling Cloudflare Workers AI API: Unknown error' (or ': <detail text>') - the raw message never escapes.
Source
Thrown at clients/js/packages/chromadb-core/src/embeddings/CloudflareWorkersAIEmbeddingFunction.ts:79
};
}
public async generate(texts: string[]) {
try {
const payload = {
text: texts,
};
const response = await fetch(this.api_url, {
method: "POST",
headers: this.headers,
body: JSON.stringify(payload),
});
const resp = await response.json();
if (!resp.result || !resp.result.data) {
throw new Error(resp.detail || "Unknown error");
}
return resp.result.data;
} catch (error) {
if (error instanceof Error) {
throw new Error(
`Error calling Cloudflare Workers AI API: ${error.message}`,
);
} else {
throw new Error(`Error calling Cloudflare Workers AI API: ${error}`);
}
}
}
buildFromConfig(config: StoredConfig): CloudflareWorkersAIEmbeddingFunction {
return new CloudflareWorkersAIEmbeddingFunction({
model_name: config.model_name,
account_id: config.account_id,View on GitHub (pinned to aecdd12c8a)
Solutions
- Log the wrapped message's suffix (the detail text) - it is Cloudflare's own error description and pinpoints auth vs model vs account problems.
- Verify account_id, gateway_id and model_name against the Cloudflare dashboard; model must be a valid Workers AI model ID like '@cf/baai/bge-small-en-v1.5'.
- Confirm the API key is valid with a direct curl to the same URL before retrying through the client.
- Handle the wrapped 'Error calling Cloudflare Workers AI API:' error in generate() call sites, since the raw message is never surfaced.
Example fix
// before
const embeddings = await ef.generate(['hello']); // throws wrapped 'Unknown error'
// after
try {
const embeddings = await ef.generate(['hello']);
} catch (e) {
console.error((e as Error).message); // inspect Cloudflare detail text
throw e;
} Defensive patterns
Strategy: try-catch
Try / catch
try {
const vectors = await ef.generate(texts);
} catch (e) {
const msg = (e as Error).message;
if (msg.startsWith('Error calling Cloudflare Workers AI API:')) {
const detail = msg.slice('Error calling Cloudflare Workers AI API:'.length).trim();
// detail 'Unknown error' or Cloudflare's `detail` text -> auth/account/model issue, not transient
throw new Error(`Cloudflare Workers AI rejected the request: ${detail}`);
}
throw e;
} Prevention
- Validate model_name/account_id/gateway_id against the Cloudflare dashboard once at setup.
- Smoke-test the exact endpoint with curl when auth changes.
- Surface the wrapped message's detail suffix in logs - it carries Cloudflare's diagnosis.
When it happens
Trigger: Invalid or expired API key (401 body with detail); wrong account_id or gateway_id (404); unknown model_name; gateway/zone errors returning an error JSON; any 200-less response whose JSON body has no result.data.
Common situations: Copied a model name that does not exist for the account; free-tier or rate-limit responses; account/gateway ID mixed up; key rotated server-side while the client still holds the old one.
Related errors
- Error calling Cloudflare Workers AI API: ${error.message}
- Error calling Cloudflare Workers AI API: ${error}
- Cloudflare API key is required. Please provide it in the con
- Invalid response format from Together AI API
- Failed to generate embeddings.
AI-assisted analysis of chroma-core/chroma@aecdd12c8a (2026-08-16).
Data as JSON: /api/errors/48ecae6ecac742f1.
Report an issue: GitHub.