{"record":{"id":"ce4a6d06cc744d22","repo":"continuedev/continue","slug":"teierror","errorCode":null,"errorMessage":"teiError","messagePattern":"teiError","errorType":"exception","errorClass":"TEIEmbedError","httpStatus":null,"severity":"error","filePath":"core/llm/llms/HuggingFaceTEI.ts","lineNumber":53,"sourceCode":"    }\n\n    const resp = await this.fetch(new URL(\"embed\", this.apiBase), {\n      method: \"POST\",\n      body: JSON.stringify({\n        inputs: batch,\n      }),\n      headers,\n    });\n    if (!resp.ok) {\n      const text = await resp.text();\n      let teiError: TEIEmbedErrorResponse | null = null;\n      try {\n        teiError = JSON.parse(text);\n      } catch (e) {\n        console.log(`Failed to parse TEI embed error response:\\n${text}`, e);\n      }\n      if (teiError && (teiError.error_type || teiError.error)) {\n        throw new TEIEmbedError(teiError);\n      }\n      throw new Error(text);\n    }\n    return (await resp.json()) as number[][];\n  }\n\n  async doInfoRequest(): Promise<TEIInfoResponse> {\n    // TODO - need to use custom fetch for this request?\n    const resp = await this.fetch(new URL(\"info\", this.apiBase), {\n      method: \"GET\",\n    });\n    if (!resp.ok) {\n      throw new Error(await resp.text());\n    }\n    return (await resp.json()) as TEIInfoResponse;\n  }\n\n  async rerank(query: string, chunks: Chunk[]): Promise<number[]> {","sourceCodeStart":35,"sourceCodeEnd":71,"githubUrl":"https://github.com/continuedev/continue/blob/5522c6f44ca0ac3528b37244818fbfa39b5af470/core/llm/llms/HuggingFaceTEI.ts#L35-L71","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Inspect the wrapped TEIError fields (error_type, message) — 'ValidationError' usually means input too long; truncate or reduce chunk size","Check the TEI server logs and that the model is loaded","Verify apiBase actually points at a TEI /embed endpoint"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"null","typeGuard":"function isTEIEmbedError(e: unknown): e is { error_type: string; message?: string } {\n  return !!e && typeof e === 'object' && 'error_type' in (e as any); // wrap TEIEmbedError payload check\n}","tryCatchPattern":"try {\n  await tei.embed(chunks);\n} catch (e) {\n  if ((e as any)?.error_type === 'ValidationError') {\n    chunks = chunks.map(c => c.slice(0, 8192)); // truncate and retry\n    return tei.embed(chunks);\n  }\n  throw e;\n}","preventionTips":["Query TEI /info at startup to learn max sequence length and truncate inputs","Health-check the TEI endpoint before batch indexing jobs"],"tags":["huggingface","tei","embedding","server-error"],"backgroundTag":"embedding-server-error","analyzedSha":"5522c6f44ca0ac3528b37244818fbfa39b5af470","analyzedAt":"2026-08-27T11:28:54.683Z","schemaVersion":2},"datasetVersion":"2026-08-27T13:17:12.746Z"}