continuedev/continue · error · Error

text

Error message

text

What it means

Fallback thrown by HuggingFaceTEI._embed when the TEI server returned a non-OK response whose body either failed to parse as JSON or had no recognizable error_type/error fields. The raw response text becomes the error message, which often means an HTML error page (502/504 from a proxy) or empty body.

Source

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

    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[]> {
    const headers: Record<string, string> = {
      "Content-Type": "application/json",

View on GitHub (pinned to 5522c6f44c)

Solutions

  1. Read the raw text — if it looks like HTML, you're hitting a proxy/gateway or wrong URL; fix apiBase
  2. If 502/504, the TEI server is down or cold-starting; retry after it's healthy
  3. Confirm the endpoint returns JSON by curling it directly
Defensive patterns

Strategy: fallback

Validate before calling

const probe = await fetch(`${apiBase}/info`);
if (!probe.ok || !(probe.headers.get('content-type') ?? '').includes('json')) {
  console.warn('TEI endpoint not serving JSON; check apiBase');
}

Type guard

function isNonJsonServerError(e: unknown): boolean {
  return e instanceof Error && /^\s*<(!doctype|html)/i.test(e.message);
}

Try / catch

try { await tei.embed(chunks); }
catch (e) { if (isNonJsonServerError(e)) fallbackToDefaultEmbedder(); else throw e; }

Prevention

When it happens

Trigger: TEI endpoint returning non-JSON error bodies: gateway timeouts from a load balancer in front of the endpoint, 403/404 HTML pages from a wrong URL, or connection-level errors surfaced as plain text.

Common situations: apiBase pointing to a URL behind a proxy that returns HTML error pages, endpoint URL typo (404 page), or cloud endpoint hibernating.

Related errors


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