{"record":{"id":"472e9af6e313f1e5","repo":"nexu-io/open-design","slug":"volcengine-image-fetch-imgresp-status","errorCode":null,"errorMessage":"volcengine image fetch ${imgResp.status}","messagePattern":"volcengine image fetch (.+?)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"apps/daemon/src/media/index.ts","lineNumber":1582,"sourceCode":"  }));\n  const text = await resp.text();\n  if (!resp.ok) {\n    throw new Error(`volcengine image ${resp.status}: ${truncate(text, 240)}`);\n  }\n  let data: any;\n  try {\n    data = JSON.parse(text);\n  } catch {\n    throw new Error(`volcengine image non-JSON: ${truncate(text, 200)}`);\n  }\n  const entry = data && Array.isArray(data.data) ? data.data[0] : null;\n  if (!entry) throw new Error('volcengine image response had no data[0]');\n  let bytes;\n  if (entry.b64_json) {\n    bytes = Buffer.from(entry.b64_json, 'base64');\n  } else if (entry.url) {\n    const imgResp = await fetch(entry.url, withMediaRequestInit(ctx));\n    if (!imgResp.ok) throw new Error(`volcengine image fetch ${imgResp.status}`);\n    bytes = Buffer.from(await imgResp.arrayBuffer());\n  } else {\n    throw new Error('volcengine image response missing b64_json/url');\n  }\n  return {\n    bytes,\n    providerNote: `volcengine/${ctx.wireModel} · ${ctx.aspect} · ${bytes.length} bytes`,\n    suggestedExt: '.png',\n  };\n}\n\n// ---------------------------------------------------------------------------\n// Provider: xAI Grok Imagine.\n//\n// Docs: https://docs.x.ai/developers/model-capabilities/{images,video}/generation\n//   * Image: POST /v1/images/generations — synchronous, returns\n//            {data:[{b64_json|url}]}; we ask for b64_json so the bytes\n//            arrive in one round-trip.","sourceCodeStart":1564,"sourceCodeEnd":1600,"githubUrl":"https://github.com/nexu-io/open-design/blob/5be4028344c2eb4c667c5a97bda8f750c5597ef7/apps/daemon/src/media/index.ts#L1564-L1600","documentation":"Thrown when downloading the image bytes from `entry.url` (the URL delivery path, used when Volcengine returns a URL instead of `b64_json`) fails with `!imgResp.ok`. Usually a transient CDN error or an expired signed link.","triggerScenarios":"`imgResp.ok === false` on `fetch(entry.url)` after the Seedream call returned a `url` field. Causes: object-storage CDN transient 5xx, a signed URL that already expired, or a network/proxy blocking the image host.","commonSituations":"(1) CDN transient 5xx; (2) network policy blocking the image-storage host; (3) delay between generation and download expiring the link.","solutions":["Retry the render; the image fetch is idempotent against transient CDN errors.","Ensure the Volcengine image-storage host is reachable from the daemon host.","If persistent, request `b64_json` delivery (already set in the body) to avoid the URL hop."],"exampleFix":null,"handlingStrategy":"retry","validationCode":null,"typeGuard":null,"tryCatchPattern":"// URL-fetch failures are transient — retry the whole render.\ntry { return await renderVolcengineImage(ctx, credentials); }\ncatch (err) {\n  const msg = err instanceof Error ? err.message : String(err);\n  if (/image fetch 5\\d{2}/.test(msg)) { return await renderVolcengineImage(ctx, credentials); }\n  throw err;\n}","preventionTips":["Treat image URL fetch failures as transient and retry.","Allowlist the Volcengine image-storage host on restricted networks.","Prefer `b64_json` delivery (already requested in the body) to avoid the URL hop."],"tags":["volcengine","ark","seedream","image","download"],"backgroundTag":null,"analyzedSha":"5be4028344c2eb4c667c5a97bda8f750c5597ef7","analyzedAt":"2026-08-12T12:03:58.812Z","schemaVersion":2},"datasetVersion":"2026-08-12T18:17:37.767Z"}