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
- Capture the raw text from the error message and inspect what was actually returned
- Bypass or configure the HTTP proxy; verify the endpoint URL returns JSON with curl
- 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
- Treat third-party search as optional: return [] on parse failure
- Log a prefix of unexpected bodies to identify proxies/captchas early
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
- Parsing and encoding errors: unexpected token, malformed input — why parsers reject input and how to find the real culprit.
Related errors
- Failed to fetch Google search results: ${response.statusText
- Failed to parse Greptile response: ${rawText}
- No MCP connection found for ${mcpId}
- HTTP ${resp.status} ${resp.statusText}
- Malformed JSON received from Bedrock: ${decoded}
AI-assisted analysis of continuedev/continue@5522c6f44c (2026-08-27).
Data as JSON: /api/errors/28841f6431804124.
Report an issue: GitHub.