chroma-core/chroma · error

Error calling Chroma Embedding API: ${error}

Error message

Error calling Chroma Embedding API: ${error}

What it means

Fallback branch of the catch in ChromaCloudQwenEmbeddingFunction.generate(): a non-Error value was thrown inside the request block (string, number, object) and is stringified into "Error calling Chroma Embedding API: <value>". This is uncommon in Node (fetch and json() reject with Error objects) but can occur with interceptors, mocks, or runtimes that throw primitives.

Source

Thrown at clients/new-js/packages/ai-embeddings/chroma-cloud-qwen/src/index.ts:141

    };

    try {
      const response = await fetch(this.url, {
        method: "POST",
        headers: this.headers,
        body: JSON.stringify(snakeCase(body)),
      });

      const data = (await response.json()) as ChromaCloudEmbeddingsResponse;
      if (!data || !data.embeddings) {
        throw new Error("Failed to generate embeddings.");
      }
      return data.embeddings;
    } catch (error) {
      if (error instanceof Error) {
        throw new Error(`Error calling Chroma Embedding API: ${error.message}`);
      } else {
        throw new Error(`Error calling Chroma Embedding API: ${error}`);
      }
    }
  }

  public async generateForQueries(texts: string[]): Promise<number[][]> {
    if (texts.length === 0) {
      return [];
    }

    let instruction = "";
    if (this.task && this.task in this.instructions) {
      instruction =
        this.instructions[this.task][ChromaCloudQwenEmbeddingTarget.QUERY];
    }

    const body: ChromaCloudEmbeddingRequest = {
      texts,
      instructions: instruction,

View on GitHub (pinned to aecdd12c8a)

Solutions

  1. Make your fetch mocks reject with Error objects (mockRejectedValue(new Error('boom'))).
  2. Inspect the stringified value in the message to find what non-Error throw occurred.
  3. If a custom fetch polyfill is in play, prefer the global fetch implementation.

Example fix

// before (test mock)
global.fetch = jest.fn().mockRejectedValue("network boom");

// after
global.fetch = jest.fn().mockRejectedValue(new Error("network boom"));
Defensive patterns

Strategy: try-catch

Try / catch

try {
  await ef.generate(texts);
} catch (e) {
  // Message embeds a non-Error throw; surface it verbatim for diagnosis
  console.error("Embedding failed with non-Error throw:", (e as Error).message);
  throw e;
}

Prevention

When it happens

Trigger: Test frameworks or fetch mocks that reject with plain strings/objects; custom fetch polyfills throwing non-Error values; exotic runtimes whose fetch rejects with primitive values.

Common situations: Unit tests mocking global fetch with jest.fn().mockRejectedValue("boom"); older fetch shims; SDK instrumentation wrapping fetch.

Related errors


AI-assisted analysis of chroma-core/chroma@aecdd12c8a (2026-08-16). Data as JSON: /api/errors/8165d98bed37f924. Report an issue: GitHub.