{"record":{"id":"008c09834c19d9f1","repo":"abhigyanpatwari/GitNexus","slug":"embedding-endpoint-returned-err-response-status","errorCode":null,"errorMessage":"Embedding endpoint returned ${err.response.status} (${safeUrl(url)}, batch ${batchIndex})","messagePattern":"Embedding endpoint returned (.+?) \\((.+?), batch (.+?)\\)","errorType":"exception","errorClass":"HttpEmbeddingError","httpStatus":null,"severity":"error","filePath":"gitnexus/src/core/embeddings/http-client.ts","lineNumber":519,"sourceCode":"    // carried, keeping the underlying parse error in `cause` only — the body\n    // text must never reach the `sanitizeReason` fallback and leak to stderr.\n    if (err instanceof RetryableEmbeddingBodyError) {\n      throw new HttpEmbeddingError(err.terminalMessage, { cause: err.cause });\n    }\n    if (err instanceof CircuitOpenError) {\n      throw new HttpEmbeddingError(\n        `Embedding endpoint circuit open (${safeUrl(url)}, batch ${batchIndex}): retry in ${Math.ceil(err.retryAfterMs / 1000)}s`,\n        { cause: err },\n      );\n    }\n    if (err instanceof DOMException && err.name === 'TimeoutError') {\n      throw new HttpEmbeddingError(\n        `Embedding request timed out after ${timeoutMs}ms (${safeUrl(url)}, batch ${batchIndex})`,\n        { cause: err },\n      );\n    }\n    if (err instanceof ResilientFetchExhaustedError) {\n      throw new HttpEmbeddingError(\n        `Embedding endpoint returned ${err.response.status} (${safeUrl(url)}, batch ${batchIndex})`,\n        { cause: err },\n      );\n    }\n    const reason = sanitizeReason(err instanceof Error ? err.message : String(err), url, apiKey);\n    const safeCause = new Error(reason);\n    safeCause.name = err instanceof Error ? err.name : 'EmbeddingTransportError';\n    throw new HttpEmbeddingError(\n      `Embedding request failed (${safeUrl(url)}, batch ${batchIndex}): ${reason}`,\n      { cause: safeCause },\n    );\n  }\n\n  if (!resp.ok) {\n    // resilientFetch already retried 5xx/429; any non-OK response here is\n    // a terminal client error (4xx other than 429).\n    throw new HttpEmbeddingError(\n      `Embedding endpoint returned ${resp.status} (${safeUrl(url)}, batch ${batchIndex})`,","sourceCodeStart":501,"sourceCodeEnd":537,"githubUrl":"https://github.com/abhigyanpatwari/GitNexus/blob/d540b00184d71a896261ee02670da9a92d59d8f7/gitnexus/src/core/embeddings/http-client.ts#L501-L537","documentation":"An HttpEmbeddingError thrown from httpEmbedBatch's catch block when resilientFetch raises ResilientFetchExhaustedError — every retry attempt received a non-OK HTTP status that resilientFetch retries (5xx and 429), and none recovered. The message reports the final response status (err.response.status). This is the exhausted form of a server-side or rate-limit status, distinct from error 132 which is a terminal 4xx returned without retry.","triggerScenarios":"httpEmbedBatch after resilientFetch exhausts maxAttempts against a 5xx/429-returning endpoint. E.g. provider returning 503/502/500 on every attempt, or 429 with Retry-After that never lets up within the attempt budget. err.response.status carries the last status seen.","commonSituations":"Provider outage (5xx). Provider rate-limiting (429) that the backoff could not dodge because the sustained rate is too high. Model overloaded. Maintenance window returning 503. Bad gateway between you and the provider.","solutions":["Check the reported status: 429 → reduce request frequency (raise GITNEXUS_EMBEDDING_MIN_INTERVAL_MS) or request a higher provider rate limit; 5xx → check provider status page and retry later.","Increase the retry budget: GITNEXUS_EMBEDDING_MAX_ATTEMPTS (max 20) and GITNEXUS_EMBEDDING_RETRY_CAP_MS (max 300000ms) so transient outages are absorbed.","Honor provider rate limits by spacing out indexing runs.","Verify auth/model are correct (some providers return 500/503 for unknown models)."],"exampleFix":"// before\n# default retry budget exhausted against a flapping endpoint\n\n// after\nexport GITNEXUS_EMBEDDING_MAX_ATTEMPTS=5\nexport GITNEXUS_EMBEDDING_RETRY_CAP_MS=30000\nexport GITNEXUS_EMBEDDING_MIN_INTERVAL_MS=500","handlingStrategy":"retry","validationCode":"// Cannot prevent a provider 5xx/429 from the caller; probe to detect early:\nconst r = await fetch(`${URL}/embeddings`, { /* ... */ });\nif (r.status >= 500 || r.status === 429) {\n  throw new Error(`Endpoint unhealthy (HTTP ${r.status}); fix before indexing`);\n}","typeGuard":"import { isHttpEmbeddingError } from 'gitnexus';\nconst isExhaustedStatus = (e: unknown): boolean =>\n  isHttpEmbeddingError(e) &&\n  e instanceof Error &&\n  /^Embedding endpoint returned \\d{3} /.test(e.message);","tryCatchPattern":"// The library already retried; surface to the operator rather than re-looping.\ntry {\n  await httpEmbed(texts);\n} catch (e) {\n  if (isExhaustedStatus(e)) {\n    // provider is returning 5xx/429 persistently; back off the whole run\n  }\n  throw e;\n}","preventionTips":["For 429: raise GITNEXUS_EMBEDDING_MIN_INTERVAL_MS and request a higher provider quota.","For 5xx: check the provider status page before large runs.","Increase GITNEXUS_EMBEDDING_MAX_ATTEMPTS / RETRY_CAP_MS so transient outages are absorbed."],"tags":["network","endpoint","retry-exhausted","http-status","embeddings"],"backgroundTag":null,"analyzedSha":"d540b00184d71a896261ee02670da9a92d59d8f7","analyzedAt":"2026-08-12T19:50:25.132Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}