continuedev/continue · error · Error

Failed to parse Google search results: ${results}

Error message

Failed to parse Google search results: ${results}

What it means

Thrown after JSON.parse of the Google search response text fails inside getContextItems. The fetch succeeded but the body was not valid JSON — the raw text is embedded in the message. Typical causes: HTML error pages, empty bodies, or an unexpected content type from a proxy.

Source

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

      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 [
        {
          content,
          name: "Google Search",
          description: "Google Search",
        },
      ];
    } catch (e) {
      throw new Error(`Failed to parse Google search results: ${results}`);
    }
  }
}

export default GoogleContextProvider;

View on GitHub (pinned to 5522c6f44c)

Solutions

  1. Capture the raw text from the error message and inspect what was actually returned
  2. Bypass or configure the HTTP proxy; verify the endpoint URL returns JSON with curl
  3. Catch this error and fall back to no Google context rather than failing the whole request

Example fix

// before
} catch (e) {
  throw new Error(`Failed to parse Google search results: ${results}`);
}
// after
} catch (e) {
  console.error('Non-JSON Google response:', results?.slice(0, 300));
  return [];
}
Defensive patterns

Strategy: try-catch

Type guard

function isJsonResponse(s: string): boolean {
  const t = s.trim();
  return (t.startsWith('{') || t.startsWith('[')) && (() => { try { JSON.parse(t); return true; } catch { return false; } })();
}

Try / catch

try { JSON.parse(results); } catch { console.error('Non-JSON from Google:', results.slice(0,200)); return []; }

Prevention

When it happens

Trigger: The Google endpoint (or an intermediary) returns 200 with non-JSON payload: an HTML captcha/consent page, an empty body, or truncated JSON due to a proxy timeout.

Common situations: Corporate proxies or captive portals injecting HTML, Google returning an HTML error page with 200, or a truncated response on flaky networks.

Understand the failure class

Related errors


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