{"record":{"id":"5bf05b96bf4515b6","repo":"nexu-io/open-design","slug":"google-resp-status-await-resp-text-catch","errorCode":null,"errorMessage":"google ${resp.status}: ${await resp.text().catch(() => '')}","messagePattern":"google (.+?): (.+?)","errorType":"http","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"apps/daemon/src/memory-llm.ts","lineNumber":917,"sourceCode":"  const model = encodeURIComponent(provider.model);\n  const url = `${base}/v1beta/models/${model}:generateContent?key=${encodeURIComponent(provider.apiKey)}`;\n  let resp;\n  try {\n    resp = await fetch(url, {\n      method: 'POST',\n      headers: { 'content-type': 'application/json' },\n      body: JSON.stringify({\n        systemInstruction: { role: 'system', parts: [{ text: system }] },\n        contents: [{ role: 'user', parts: [{ text: user }] }],\n        generationConfig: { responseMimeType: 'application/json' },\n      }),\n      signal: withTimeout(FETCH_TIMEOUT_MS),\n    });\n  } catch (err) {\n    throw new Error(describeFetchError(err));\n  }\n  if (!resp.ok) {\n    throw new Error(`google ${resp.status}: ${await resp.text().catch(() => '')}`);\n  }\n  const json = await resp.json();\n  const parts = json?.candidates?.[0]?.content?.parts;\n  if (Array.isArray(parts)) {\n    return parts.map((p) => (p && typeof p.text === 'string' ? p.text : '')).join('');\n  }\n  return '';\n}\n\nconst LOCAL_CLI_TIMEOUT_MS = 60_000;\n\nfunction extractJsonEventText(kind, raw, agentName) {\n  const events = [];\n  const handler = createJsonEventStreamHandler(kind, (event) => events.push(event));\n  handler.feed(raw);\n  handler.flush();\n\n  const errorEvent = events.find((event) => event?.type === 'error');","sourceCodeStart":899,"sourceCodeEnd":935,"githubUrl":"https://github.com/nexu-io/open-design/blob/5be4028344c2eb4c667c5a97bda8f750c5597ef7/apps/daemon/src/memory-llm.ts#L899-L935","documentation":"The Google Gemini REST API returned a non-2xx HTTP status during the memory-LLM extraction call. Gemini uses a different request shape (systemInstruction, contents[], query-param API key) and response_format: application/json for strict JSON output. The error includes status code and raw body.","triggerScenarios":"Invalid or expired API key (passed as query parameter); model name not available; quota exceeded; safety filters triggered; malformed request; wrong baseUrl.","commonSituations":"Google API key revoked or rotated; model deprecated or not enabled for the key; baseUrl wrong or missing the model path; content safety filters rejecting the memory extraction prompt; free-tier quota exhausted.","solutions":["Verify the Google API key is valid and has Gemini API access enabled","Confirm provider.model is a current Gemini model identifier","Check provider.baseUrl points to the correct Google Generative AI endpoint","Inspect the response body for the specific error (safety blocks return 400 with finishReason)","Retry after a delay if quota-limited"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try {\n  const text = await callGoogle(provider, system, user);\n} catch (err) {\n  if (err.message.startsWith('google ')) {\n    const status = parseInt(err.message.split(' ')[1], 10);\n    if (status === 429) {\n      await sleep(backoffMs);\n      return callGoogle(provider, system, user);\n    }\n    if (status === 400) {\n      // Could be a safety filter block — inspect the body\n      throw new Error('Google Gemini rejected the request (possibly safety filter): ' + err.message);\n    }\n  }\n  throw err;\n}","preventionTips":["Verify the Google API key has Gemini API access enabled in Google Cloud","Confirm provider.model is a current Gemini model identifier","Be aware that safety filters can reject prompts — design extraction prompts to avoid triggering them","Monitor free-tier quota limits which are lower than paid tiers"],"tags":["google","gemini","llm","http","memory-extraction","network"],"backgroundTag":null,"analyzedSha":"5be4028344c2eb4c667c5a97bda8f750c5597ef7","analyzedAt":"2026-08-12T12:03:58.812Z","schemaVersion":2},"datasetVersion":"2026-08-12T18:17:37.767Z"}