{"record":{"id":"b4bbb7c1d6124afd","repo":"nexu-io/open-design","slug":"azure-resp-status-await-resp-text-catch","errorCode":null,"errorMessage":"azure ${resp.status}: ${await resp.text().catch(() => '')}","messagePattern":"azure (.+?): (.+?)","errorType":"http","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"apps/daemon/src/memory-llm.ts","lineNumber":886,"sourceCode":"      method: 'POST',\n      headers: {\n        'content-type': 'application/json',\n        'api-key': provider.apiKey,\n      },\n      body: JSON.stringify({\n        response_format: { type: 'json_object' },\n        messages: [\n          { role: 'system', content: system },\n          { role: 'user', content: user },\n        ],\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(`azure ${resp.status}: ${await resp.text().catch(() => '')}`);\n  }\n  const json = await resp.json();\n  return json?.choices?.[0]?.message?.content ?? '';\n}\n\n// Google Gemini's REST surface uses a different request shape:\n// system instructions go in `systemInstruction`, the conversation is\n// `contents[]` with `role` + `parts`, and the API key is a query\n// parameter rather than a header. `responseMimeType: application/json`\n// gets us the strict JSON output the parser expects.\nasync function callGoogle(provider, system, user) {\n  const base = String(provider.baseUrl || '').replace(/\\/+$/, '');\n  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',","sourceCodeStart":868,"sourceCodeEnd":904,"githubUrl":"https://github.com/nexu-io/open-design/blob/5be4028344c2eb4c667c5a97bda8f750c5597ef7/apps/daemon/src/memory-llm.ts#L868-L904","documentation":"The Azure OpenAI Chat Completions API returned a non-2xx HTTP status during the memory-LLM extraction call. Azure uses a per-deployment URL and api-key header instead of Authorization. The provider.model field is the Azure deployment name, not the model family. The error includes status code and raw body.","triggerScenarios":"Invalid Azure API key (401/403); the deployment name in provider.model doesn't exist in the Azure resource; baseUrl doesn't include the correct deployment path; rate limiting (429); quota exceeded.","commonSituations":"Azure API key rotated in the portal without updating daemon config; deployment deleted or renamed; baseUrl missing or wrong format (must include resource and deployment); confusion between model family name and deployment name.","solutions":["Verify the Azure API key is current and has access to the deployment","Confirm provider.model is the exact Azure deployment name (not the model family like 'gpt-4')","Check provider.baseUrl includes the correct resource name and deployment path","Inspect the response body for the specific Azure error code","Retry after a delay if rate-limited (429)"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try {\n  const text = await callAzure(provider, system, user);\n} catch (err) {\n  if (err.message.startsWith('azure ')) {\n    const status = parseInt(err.message.split(' ')[1], 10);\n    if (status === 429) {\n      await sleep(backoffMs);\n      return callAzure(provider, system, user);\n    }\n    if (status === 401 || status === 403) {\n      throw new Error('Azure OpenAI API key is invalid or lacks deployment access');\n    }\n  }\n  throw err;\n}","preventionTips":["Use the Azure deployment name (not the model family) as provider.model","Verify the Azure API key has access to the specific deployment","Confirm provider.baseUrl includes the correct resource and deployment path format","Rotate Azure API keys through the portal and update daemon config promptly"],"tags":["azure","openai","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"}