{"record":{"id":"c8530896588df094","repo":"continuedev/continue","slug":"await-resp-text-c85308","errorCode":null,"errorMessage":"await resp.text()","messagePattern":"await resp\\.text\\(\\)","errorType":"http","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"core/llm/llms/FunctionNetwork.ts","lineNumber":55,"sourceCode":"  public supportsPrefill(): boolean {\n    return false;\n  }\n\n  protected async _embed(chunks: string[]): Promise<number[][]> {\n    const resp = await this.fetch(new URL(\"embeddings\", this.apiBase), {\n      method: \"POST\",\n      body: JSON.stringify({\n        input: chunks,\n        model: this.model,\n      }),\n      headers: {\n        Authorization: `Bearer ${this.apiKey}`,\n        \"Content-Type\": \"application/json\",\n      },\n    });\n\n    if (!resp.ok) {\n      throw new Error(await resp.text());\n    }\n\n    const data = (await resp.json()) as any;\n    return data.data.map((result: { embedding: number[] }) => result.embedding);\n  }\n}\n\nexport default FunctionNetwork;\n","sourceCodeStart":37,"sourceCodeEnd":64,"githubUrl":"https://github.com/continuedev/continue/blob/5522c6f44ca0ac3528b37244818fbfa39b5af470/core/llm/llms/FunctionNetwork.ts#L37-L64","documentation":"Thrown by the FunctionNetwork embedder._embed when the POST to the embeddings endpoint returns a non-2xx status; the raw response body text becomes the error message. The body carries FunctionNetwork's error payload identifying auth, model, or validation failures.","triggerScenarios":"Calling embed() with a missing/invalid FunctionNetwork API key (401), an embedding model name not offered by the endpoint (404/400), inputs array exceeding endpoint batch/token limits, or rate limiting (429).","commonSituations":"FUNCTIONNETWORK_API_KEY env var unset or with stray quotes, model slugs copied from OpenAI docs, bulk indexing hitting per-request input limits or QPS caps.","solutions":["Read the response body embedded in the message to identify the exact endpoint error","Verify FUNCTIONNETWORK_API_KEY is set/valid with a single-input curl test against the embeddings endpoint","Confirm the configured embedding model name is valid for FunctionNetwork","Batch inputs within limits and add backoff for 429s"],"exampleFix":null,"handlingStrategy":"validation","validationCode":"if (!process.env.FUNCTIONNETWORK_API_KEY) throw new Error('FUNCTIONNETWORK_API_KEY missing');\nconst batch = texts.slice(0, 64); // stay within batch limits","typeGuard":"function isFunctionNetworkEmbedError(e: unknown): boolean {\n  return e instanceof Error && !(e instanceof TypeError) && /embed|api|key|limit/i.test(e.message);\n}","tryCatchPattern":"try { await embedder.embed(batch); }\ncatch (e) {\n  if (e instanceof Error && /401|unauthorized|api key/i.test(e.message)) throw new ConfigError('Bad FUNCTIONNETWORK_API_KEY');\n  throw e;\n}","preventionTips":["Validate the API key with a minimal embed at startup","Batch inputs within provider limits","Trim env var whitespace"],"tags":["functionnetwork","embeddings","api-key","response-error"],"backgroundTag":"embedding-api-error","analyzedSha":"5522c6f44ca0ac3528b37244818fbfa39b5af470","analyzedAt":"2026-08-27T11:28:54.683Z","schemaVersion":2},"datasetVersion":"2026-08-27T13:17:12.746Z"}