continuedev/continue · error · TEIEmbedError

teiError

Error message

teiError

What it means

Thrown by HuggingFaceTEI._embed when the Text Embeddings Inference server returns an error payload that TEIError could not parse — this specific line is the structured TEIEmbedError wrapping the server's error_type/error fields. It fires only when the TEI server responded with a recognizable JSON error structure.

Source

Thrown at core/llm/llms/HuggingFaceTEI.ts:53

    }

    const resp = await this.fetch(new URL("embed", this.apiBase), {
      method: "POST",
      body: JSON.stringify({
        inputs: batch,
      }),
      headers,
    });
    if (!resp.ok) {
      const text = await resp.text();
      let teiError: TEIEmbedErrorResponse | null = null;
      try {
        teiError = JSON.parse(text);
      } catch (e) {
        console.log(`Failed to parse TEI embed error response:\n${text}`, e);
      }
      if (teiError && (teiError.error_type || teiError.error)) {
        throw new TEIEmbedError(teiError);
      }
      throw new Error(text);
    }
    return (await resp.json()) as number[][];
  }

  async doInfoRequest(): Promise<TEIInfoResponse> {
    // TODO - need to use custom fetch for this request?
    const resp = await this.fetch(new URL("info", this.apiBase), {
      method: "GET",
    });
    if (!resp.ok) {
      throw new Error(await resp.text());
    }
    return (await resp.json()) as TEIInfoResponse;
  }

  async rerank(query: string, chunks: Chunk[]): Promise<number[]> {

View on GitHub (pinned to 5522c6f44c)

Solutions

  1. Inspect the wrapped TEIError fields (error_type, message) — 'ValidationError' usually means input too long; truncate or reduce chunk size
  2. Check the TEI server logs and that the model is loaded
  3. Verify apiBase actually points at a TEI /embed endpoint
Defensive patterns

Strategy: try-catch

Validate before calling

null

Type guard

function isTEIEmbedError(e: unknown): e is { error_type: string; message?: string } {
  return !!e && typeof e === 'object' && 'error_type' in (e as any); // wrap TEIEmbedError payload check
}

Try / catch

try {
  await tei.embed(chunks);
} catch (e) {
  if ((e as any)?.error_type === 'ValidationError') {
    chunks = chunks.map(c => c.slice(0, 8192)); // truncate and retry
    return tei.embed(chunks);
  }
  throw e;
}

Prevention

When it happens

Trigger: POSTing embeddings to a TEI server that returns JSON containing error_type or error — e.g. context-length overflow, model load failure, or 4xx/5xx from the server.

Common situations: Chunk longer than the model's max sequence length, TEI server restarted without the model loaded, or wrong apiBase pointing at a non-TEI service that returns JSON errors.

Related errors


AI-assisted analysis of continuedev/continue@5522c6f44c (2026-08-27). Data as JSON: /api/errors/ce4a6d06cc744d22. Report an issue: GitHub.