{"record":{"id":"28841f6431804124","repo":"continuedev/continue","slug":"failed-to-parse-google-search-results-results","errorCode":null,"errorMessage":"Failed to parse Google search results: ${results}","messagePattern":"Failed to parse Google search results: (.+?)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"core/context/providers/GoogleContextProvider.ts","lineNumber":72,"sourceCode":"      const answerBox = parsed.answerBox;\n\n      if (answerBox) {\n        content += `Answer Box (${answerBox.title}): ${answerBox.answer}\\n\\n`;\n      }\n\n      for (const result of parsed.organic) {\n        content += `${result.title}\\n${result.link}\\n${result.snippet}\\n\\n`;\n      }\n\n      return [\n        {\n          content,\n          name: \"Google Search\",\n          description: \"Google Search\",\n        },\n      ];\n    } catch (e) {\n      throw new Error(`Failed to parse Google search results: ${results}`);\n    }\n  }\n}\n\nexport default GoogleContextProvider;\n","sourceCodeStart":54,"sourceCodeEnd":78,"githubUrl":"https://github.com/continuedev/continue/blob/5522c6f44ca0ac3528b37244818fbfa39b5af470/core/context/providers/GoogleContextProvider.ts#L54-L78","documentation":"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.","triggerScenarios":"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.","commonSituations":"Corporate proxies or captive portals injecting HTML, Google returning an HTML error page with 200, or a truncated response on flaky networks.","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"],"exampleFix":"// before\n} catch (e) {\n  throw new Error(`Failed to parse Google search results: ${results}`);\n}\n// after\n} catch (e) {\n  console.error('Non-JSON Google response:', results?.slice(0, 300));\n  return [];\n}","handlingStrategy":"try-catch","validationCode":null,"typeGuard":"function isJsonResponse(s: string): boolean {\n  const t = s.trim();\n  return (t.startsWith('{') || t.startsWith('[')) && (() => { try { JSON.parse(t); return true; } catch { return false; } })();\n}","tryCatchPattern":"try { JSON.parse(results); } catch { console.error('Non-JSON from Google:', results.slice(0,200)); return []; }","preventionTips":["Treat third-party search as optional: return [] on parse failure","Log a prefix of unexpected bodies to identify proxies/captchas early"],"tags":["json","parse","google-search","context-provider"],"backgroundTag":"invalid-json-response","analyzedSha":"5522c6f44ca0ac3528b37244818fbfa39b5af470","analyzedAt":"2026-08-27T11:28:54.683Z","schemaVersion":2},"datasetVersion":"2026-08-27T13:17:12.746Z"}