{"record":{"id":"c33f0c325c90910c","repo":"nexu-io/open-design","slug":"volcengine-image-resp-status-truncate-text","errorCode":null,"errorMessage":"volcengine image ${resp.status}: ${truncate(text, 240)}","messagePattern":"volcengine image (.+?): (.+?)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"apps/daemon/src/media/index.ts","lineNumber":1567,"sourceCode":"    model: ctx.wireModel,\n    prompt: ctx.prompt || 'A high-quality reference image.',\n    response_format: 'b64_json',\n    // openaiSizeFor branches on the catalog id (gpt-image-* vs dall-e-*\n    // accept different size enums), so it must NOT see the post-alias\n    // wire name. lefarcen + codex P2 on PR #1309.\n    size: openaiSizeFor(ctx.model, ctx.aspect),\n  };\n  const resp = await fetch(`${baseUrl}/images/generations`, withMediaRequestInit(ctx, {\n    method: 'POST',\n    headers: {\n      'authorization': `Bearer ${credentials.apiKey}`,\n      'content-type': 'application/json',\n    },\n    body: JSON.stringify(body),\n  }));\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');","sourceCodeStart":1549,"sourceCodeEnd":1585,"githubUrl":"https://github.com/nexu-io/open-design/blob/5be4028344c2eb4c667c5a97bda8f750c5597ef7/apps/daemon/src/media/index.ts#L1549-L1585","documentation":"Thrown when the Seedream `POST /api/v3/images/generations` returns a non-2xx status. The message carries the HTTP status plus up to 240 chars of body, surfacing the Volcengine error (auth, model-not-enabled, invalid size/aspect).","triggerScenarios":"`resp.ok === false` on the Seedream image call. Concretely: 401 from a wrong/expired ARK key, 403/permission-denied because the Seedream model isn't activated, 400 from an unsupported `size`/`aspect` mapping (via `openaiSizeFor`), or 429 quota exhaustion.","commonSituations":"(1) ARK key valid but Seedream model not subscribed/activated in the Volcengine console; (2) aspect ratio not mappable to a supported size; (3) account out of image quota; (4) `baseUrl` overridden to a region that doesn't host the model.","solutions":["Inspect the embedded status+body: 401 → fix key; 403/'permission denied' → enable the Seedream model in the Volcengine console; 400 → adjust aspect; 429 → wait for quota reset.","Ensure `ctx.wireModel` matches an activated Ark endpoint id or model name.","Confirm the `baseUrl` resolves to the correct regional Ark host."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try {\n  return await renderVolcengineImage(ctx, credentials);\n} catch (err) {\n  const msg = err instanceof Error ? err.message : String(err);\n  if (/image 40[13]/.test(msg)) { throw new Error('Volcengine auth failed — check ARK_API_KEY'); }\n  if (/permission|forbidden/i.test(msg)) { throw new Error('Seedream model not activated for this account'); }\n  if (/image 429/.test(msg)) { /* quota — back off */ }\n  throw err;\n}","preventionTips":["Activate the Seedream model in the Volcengine console before first use.","Confirm the aspect ratio maps to a supported `size` via `openaiSizeFor`.","Keep the ARK key valid and within quota."],"tags":["volcengine","ark","seedream","image","provider-error"],"backgroundTag":null,"analyzedSha":"5be4028344c2eb4c667c5a97bda8f750c5597ef7","analyzedAt":"2026-08-12T12:03:58.812Z","schemaVersion":2},"datasetVersion":"2026-08-12T18:17:37.767Z"}