{"record":{"id":"9712f485e826646d","repo":"nexu-io/open-design","slug":"volcengine-image-response-missing-b64-json-url","errorCode":null,"errorMessage":"volcengine image response missing b64_json/url","messagePattern":"volcengine image response missing b64_json/url","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"apps/daemon/src/media/index.ts","lineNumber":1585,"sourceCode":"    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.\n//   * Video: POST /v1/videos/generations — may return the finished video\n//            inline ({status:'done', video:{url}}) or an async stub\n//            ({id, status:'pending'}); in the async case we poll","sourceCodeStart":1567,"sourceCodeEnd":1603,"githubUrl":"https://github.com/nexu-io/open-design/blob/5be4028344c2eb4c667c5a97bda8f750c5597ef7/apps/daemon/src/media/index.ts#L1567-L1603","documentation":"Thrown when the `data[0]` entry has neither `b64_json` nor `url`. The renderer supports both delivery modes; an entry with neither is an unexpected/unsupported response shape (new field, API change, or partial body).","triggerScenarios":"Parsed `entry` where both `entry.b64_json` and `entry.url` are falsy. Happens on an API shape change (Volcengine adds a new delivery field), a partial/error entry returned with 2xx, or a `baseUrl` override returning a different schema.","commonSituations":"(1) Volcengine shipped an API change introducing a new field name; (2) error entry returned inside `data` with 2xx; (3) wrong API path returning a non-Seedream envelope.","solutions":["Log the full `entry` object to see which fields Volcengine actually returned.","Verify the API path is `/api/v3/images/generations` and the model is a Seedream image model.","If a new delivery field appears, extend the `b64_json`/`url` branch in the renderer."],"exampleFix":"// before\nif (entry.b64_json) { bytes = Buffer.from(entry.b64_json, 'base64'); }\nelse if (entry.url) { /* fetch url */ }\nelse { throw new Error('volcengine image response missing b64_json/url'); }\n\n// after (also accept a future revised_payload / base64 field)\nconst b64 = entry.b64_json || entry.b64 || entry.revised_payload;\nif (b64) { bytes = Buffer.from(b64, 'base64'); }\nelse if (entry.url) { /* fetch url */ }\nelse { throw new Error(`volcengine image response missing b64_json/url; keys=${Object.keys(entry).join(',')}`); }","handlingStrategy":"type-guard","validationCode":null,"typeGuard":"type VolcengineImageEntry = { b64_json?: string; url?: string };\nfunction hasImagePayload(e: unknown): e is VolcengineImageEntry {\n  const o = e as any;\n  return typeof o?.b64_json === 'string' || typeof o?.url === 'string';\n}\nif (!hasImagePayload(entry)) {\n  throw new Error(`volcengine image response missing b64_json/url; keys=${Object.keys(entry).join(',')}`);\n}","tryCatchPattern":null,"preventionTips":["Log the entry keys when neither field is present to catch API shape changes early.","Pin the API path to `/api/v3/images/generations`.","Extend the b64_json/url branch when Volcengine introduces a new delivery field."],"tags":["volcengine","ark","seedream","response-shape"],"backgroundTag":null,"analyzedSha":"5be4028344c2eb4c667c5a97bda8f750c5597ef7","analyzedAt":"2026-08-12T12:03:58.812Z","schemaVersion":2},"datasetVersion":"2026-08-12T18:17:37.767Z"}