{"record":{"id":"ad1c3282a85eae56","repo":"nexu-io/open-design","slug":"volcengine-image-non-json-truncate-text-200","errorCode":null,"errorMessage":"volcengine image non-JSON: ${truncate(text, 200)}","messagePattern":"volcengine image non-JSON: (.+?)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"apps/daemon/src/media/index.ts","lineNumber":1573,"sourceCode":"    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');\n  }\n  return {\n    bytes,\n    providerNote: `volcengine/${ctx.wireModel} · ${ctx.aspect} · ${bytes.length} bytes`,\n    suggestedExt: '.png',\n  };","sourceCodeStart":1555,"sourceCodeEnd":1591,"githubUrl":"https://github.com/nexu-io/open-design/blob/5be4028344c2eb4c667c5a97bda8f750c5597ef7/apps/daemon/src/media/index.ts#L1555-L1591","documentation":"Thrown when `JSON.parse(text)` fails on the Seedream image response. Volcengine (or an intermediary) returned a 2xx body that isn't JSON — typically an HTML gateway/maintenance page — so up to 200 chars are surfaced for diagnosis.","triggerScenarios":"2xx Seedream response that fails `JSON.parse`. Gateway maintenance page, proxy HTML interstitial, captive-portal auth wall, or a `baseUrl` override pointing at a host that serves HTML.","commonSituations":"(1) Volcengine regional outage surfacing an HTML status page with a 2xx status; (2) corporate proxy injecting an HTML interstitial; (3) `baseUrl` mistyped.","solutions":["Inspect the truncated body — HTML indicates a gateway/proxy; fix routing or wait out the outage.","Verify `credentials.baseUrl` (or unset it to use the default Ark host).","Ensure the Ark host is reachable and not redirected on the daemon's network."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"function looksLikeArkJson(text: string): boolean {\n  const head = text.slice(0, 100).trim();\n  return head.startsWith('{') || head.startsWith('[');\n}","typeGuard":null,"tryCatchPattern":"try { data = JSON.parse(text); }\ncatch { throw new Error(`volcengine image non-JSON: ${truncate(text, 200)}`); }","preventionTips":["Confirm the daemon host reaches the Ark host without an HTML redirect.","Avoid overriding `baseUrl` unless you control the target.","Log the response `Content-Type` to catch gateway HTML early."],"tags":["volcengine","ark","seedream","json","network"],"backgroundTag":null,"analyzedSha":"5be4028344c2eb4c667c5a97bda8f750c5597ef7","analyzedAt":"2026-08-12T12:03:58.812Z","schemaVersion":2},"datasetVersion":"2026-08-12T18:17:37.767Z"}