continuedev/continue · error · Error

Failed to fetch Google search results: ${response.statusText

Error message

Failed to fetch Google search results: ${response.statusText}

What it means

Thrown when the Google Custom Search (or proxied Google search) API returns a non-2xx status for the POST request issued in GoogleContextProvider.getContextItems. The provider only includes response.statusText in the message, so the status text is the only clue; the raw body is not surfaced. It is a plain fetch !response.ok guard.

Source

Thrown at core/context/providers/GoogleContextProvider.ts:46

    query: string,
    extras: ContextProviderExtras,
  ): Promise<ContextItem[]> {
    const url = "https://google.serper.dev/search";

    const payload = JSON.stringify({ q: query });
    const headers = {
      "X-API-KEY": this._serperApiKey,
      "Content-Type": "application/json",
    };

    const response = await extras.fetch(url, {
      method: "POST",
      headers: headers,
      body: payload,
    });

    if (!response.ok) {
      throw new Error(
        `Failed to fetch Google search results: ${response.statusText}`,
      );
    }
    const results = await response.text();
    try {
      const parsed = JSON.parse(results);
      let content = `Google Search: ${query}\n\n`;
      const answerBox = parsed.answerBox;

      if (answerBox) {
        content += `Answer Box (${answerBox.title}): ${answerBox.answer}\n\n`;
      }

      for (const result of parsed.organic) {
        content += `${result.title}\n${result.link}\n${result.snippet}\n\n`;
      }

      return [

View on GitHub (pinned to 5522c6f44c)

Solutions

  1. Check the provider options (apiKey, engine ID / endpoint) in config.yaml and re-run with a trivial query
  2. Test the same request with curl to see the actual status and body from Google
  3. Verify quota and billing on the Google Cloud console if status is 429/403
  4. Wrap the provider usage in a try/catch or disable the provider if Google search is optional

Example fix

// before
if (!response.ok) {
  throw new Error(`Failed to fetch Google search results: ${response.statusText}`);
}
// after (surface status code and body)
if (!response.ok) {
  const body = await response.text();
  throw new Error(`Failed to fetch Google search results: ${response.status} ${response.statusText}: ${body.slice(0, 200)}`);
}
Defensive patterns

Strategy: try-catch

Validate before calling

// Validate provider options before enabling
const opts = provider.options ?? {};
if (!opts.apiKey) throw new Error('Google provider needs apiKey');

Try / catch

try {
  const items = await provider.getContextItems(q, extras);
} catch (e) {
  if (e instanceof Error && e.message.startsWith('Failed to fetch Google search results')) {
    return []; // degrade without Google context
  }
  throw e;
}

Prevention

When it happens

Trigger: Calling the @google context provider with a query when the Google API endpoint responds with 4xx/5xx: invalid/expired API key, malformed search engine ID, quota exhaustion (429), or network proxy returning an error page.

Common situations: Missing or wrong GOOGLE_SEARCH_API_KEY / search engine CX configuration, exceeded Google API daily quota, or the custom search endpoint URL is blocked/rewritten by a corporate proxy.

Related errors


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