{"record":{"id":"1c11a05fd2060480","repo":"continuedev/continue","slug":"failed-to-fetch-google-search-results-response","errorCode":null,"errorMessage":"Failed to fetch Google search results: ${response.statusText}","messagePattern":"Failed to fetch Google search results: (.+?)","errorType":"http","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"core/context/providers/GoogleContextProvider.ts","lineNumber":46,"sourceCode":"    query: string,\n    extras: ContextProviderExtras,\n  ): Promise<ContextItem[]> {\n    const url = \"https://google.serper.dev/search\";\n\n    const payload = JSON.stringify({ q: query });\n    const headers = {\n      \"X-API-KEY\": this._serperApiKey,\n      \"Content-Type\": \"application/json\",\n    };\n\n    const response = await extras.fetch(url, {\n      method: \"POST\",\n      headers: headers,\n      body: payload,\n    });\n\n    if (!response.ok) {\n      throw new Error(\n        `Failed to fetch Google search results: ${response.statusText}`,\n      );\n    }\n    const results = await response.text();\n    try {\n      const parsed = JSON.parse(results);\n      let content = `Google Search: ${query}\\n\\n`;\n      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 [","sourceCodeStart":28,"sourceCodeEnd":64,"githubUrl":"https://github.com/continuedev/continue/blob/5522c6f44ca0ac3528b37244818fbfa39b5af470/core/context/providers/GoogleContextProvider.ts#L28-L64","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Check the provider options (apiKey, engine ID / endpoint) in config.yaml and re-run with a trivial query","Test the same request with curl to see the actual status and body from Google","Verify quota and billing on the Google Cloud console if status is 429/403","Wrap the provider usage in a try/catch or disable the provider if Google search is optional"],"exampleFix":"// before\nif (!response.ok) {\n  throw new Error(`Failed to fetch Google search results: ${response.statusText}`);\n}\n// after (surface status code and body)\nif (!response.ok) {\n  const body = await response.text();\n  throw new Error(`Failed to fetch Google search results: ${response.status} ${response.statusText}: ${body.slice(0, 200)}`);\n}","handlingStrategy":"try-catch","validationCode":"// Validate provider options before enabling\nconst opts = provider.options ?? {};\nif (!opts.apiKey) throw new Error('Google provider needs apiKey');","typeGuard":null,"tryCatchPattern":"try {\n  const items = await provider.getContextItems(q, extras);\n} catch (e) {\n  if (e instanceof Error && e.message.startsWith('Failed to fetch Google search results')) {\n    return []; // degrade without Google context\n  }\n  throw e;\n}","preventionTips":["Keep Google API keys and engine IDs in provider options validated at config load","Monitor Google API quota dashboards","Wrap optional context providers so one failure doesn't break a chat request"],"tags":["google-search","api","http","context-provider"],"backgroundTag":"http-api-error-response","analyzedSha":"5522c6f44ca0ac3528b37244818fbfa39b5af470","analyzedAt":"2026-08-27T11:28:54.683Z","schemaVersion":2},"datasetVersion":"2026-08-27T13:17:12.746Z"}