continuedev/continue · error · Error

AskSage client error: ${error.message}

Error message

AskSage client error: ${error.message}

What it means

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.

Source

Thrown at packages/openai-adapters/src/apis/AskSage.ts:370

      if (!response.ok) {
        const errText = await response.text();

        // Clear token cache on 401
        if (response.status === 401) {
          this.clearTokenCache();
        }

        throw new Error(
          `AskSage API error: ${response.status} ${response.statusText}: ${errText}`,
        );
      }

      const data = (await response.json()) as AskSageResponse;
      return this.parseResponse(data, body.model);
    } catch (error) {
      if (error instanceof Error) {
        throw new Error(`AskSage client error: ${error.message}`);
      }
      throw error;
    }
  }

  async *chatCompletionStream(
    body: ChatCompletionCreateParamsStreaming,
    signal: AbortSignal,
  ): AsyncGenerator<ChatCompletionChunk> {
    // AskSage API may not support true SSE streaming
    // Implement as non-streaming call that yields chunks
    const requestBody = this.buildRequestBody(body);
    const endpoint = `${this.apiBase.replace(/\/$/, "")}/query`;

    try {
      const headers = await this.getHeaders();
      const response = await this.fetchFn(endpoint, {
        method: "POST",

View on GitHub (pinned to 5522c6f44c)

Solutions

  1. Inspect error.message — 'Unexpected token < in JSON' means a gateway HTML page: check the URL and network egress
  2. For ECONNRESET/socket errors, add retry with backoff
  3. Log the raw response (status/headers/text) before json() to diagnose
  4. Verify the AskSage base URL is correct and reachable
Defensive patterns

Strategy: try-catch

Validate before calling

const text = await response.text();
if (!text.trim().startsWith('{')) throw new Error('Non-JSON response from gateway');

Try / catch

catch (e) {
  if (/AskSage client error: .*Unexpected token/.test(String(e))) { logger.error('Gateway returned HTML — check network/proxy'); }
  if (/ECONNRESET|socket hang up/.test(String(e))) return await withBackoff(call);
  throw e;
}

Prevention

When it happens

Trigger: 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).

Common situations: Corporate proxies or Cloudflare-style gateways intercepting the request; transient network failures; server returning 200 with empty body.

Related errors


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