{"record":{"id":"3085ec03ed02c6e9","repo":"continuedev/continue","slug":"asksage-client-error-error-message-3085ec","errorCode":null,"errorMessage":"AskSage client error: ${error.message}","messagePattern":"AskSage client error: (.+?)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/openai-adapters/src/apis/AskSage.ts","lineNumber":370,"sourceCode":"\n      if (!response.ok) {\n        const errText = await response.text();\n\n        // Clear token cache on 401\n        if (response.status === 401) {\n          this.clearTokenCache();\n        }\n\n        throw new Error(\n          `AskSage API error: ${response.status} ${response.statusText}: ${errText}`,\n        );\n      }\n\n      const data = (await response.json()) as AskSageResponse;\n      return this.parseResponse(data, body.model);\n    } catch (error) {\n      if (error instanceof Error) {\n        throw new Error(`AskSage client error: ${error.message}`);\n      }\n      throw error;\n    }\n  }\n\n  async *chatCompletionStream(\n    body: ChatCompletionCreateParamsStreaming,\n    signal: AbortSignal,\n  ): AsyncGenerator<ChatCompletionChunk> {\n    // AskSage API may not support true SSE streaming\n    // Implement as non-streaming call that yields chunks\n    const requestBody = this.buildRequestBody(body);\n    const endpoint = `${this.apiBase.replace(/\\/$/, \"\")}/query`;\n\n    try {\n      const headers = await this.getHeaders();\n      const response = await this.fetchFn(endpoint, {\n        method: \"POST\",","sourceCodeStart":352,"sourceCodeEnd":388,"githubUrl":"https://github.com/continuedev/continue/blob/5522c6f44ca0ac3528b37244818fbfa39b5af470/packages/openai-adapters/src/apis/AskSage.ts#L352-L388","documentation":"A non-Error exception (or the JSON parse of a non-JSON error body) occurred during the non-streaming AskSage chat call; the adapter wraps any caught Error with the 'AskSage client error:' prefix. Commonly this wraps a JSON parse failure when the response body isn't valid JSON.","triggerScenarios":"AskSage returning HTML/plain-text error pages (gateway timeouts, WAF blocks) that fail response.json(); network errors surfacing as Error objects (ECONNRESET, socket hang up).","commonSituations":"Corporate proxies or Cloudflare-style gateways intercepting the request; transient network failures; server returning 200 with empty body.","solutions":["Inspect error.message — 'Unexpected token < in JSON' means a gateway HTML page: check the URL and network egress","For ECONNRESET/socket errors, add retry with backoff","Log the raw response (status/headers/text) before json() to diagnose","Verify the AskSage base URL is correct and reachable"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"const text = await response.text();\nif (!text.trim().startsWith('{')) throw new Error('Non-JSON response from gateway');","typeGuard":null,"tryCatchPattern":"catch (e) {\n  if (/AskSage client error: .*Unexpected token/.test(String(e))) { logger.error('Gateway returned HTML — check network/proxy'); }\n  if (/ECONNRESET|socket hang up/.test(String(e))) return await withBackoff(call);\n  throw e;\n}","preventionTips":["Distinguish parse errors from transport errors in the wrapped message","Log raw bodies when debugging gateway interference"],"tags":["asksage","json-parse","network"],"backgroundTag":"invalid-json-response","analyzedSha":"5522c6f44ca0ac3528b37244818fbfa39b5af470","analyzedAt":"2026-08-27T11:28:54.683Z","schemaVersion":2},"datasetVersion":"2026-08-27T13:17:12.746Z"}