{"record":{"id":"0ff8d6386362e97a","repo":"nexu-io/open-design","slug":"volcengine-non-json-truncate-tasktext-200","errorCode":null,"errorMessage":"volcengine non-JSON: ${truncate(taskText, 200)}","messagePattern":"volcengine non-JSON: (.+?)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"apps/daemon/src/media/index.ts","lineNumber":1455,"sourceCode":"  };\n\n  const taskResp = await fetch(`${baseUrl}/contents/generations/tasks`, withMediaRequestInit(ctx, {\n    method: 'POST',\n    headers: {\n      'authorization': `Bearer ${credentials.apiKey}`,\n      'content-type': 'application/json',\n    },\n    body: JSON.stringify(taskBody),\n  }));\n  const taskText = await taskResp.text();\n  if (!taskResp.ok) {\n    throw new Error(`volcengine task create ${taskResp.status}: ${truncate(taskText, 240)}`);\n  }\n  let taskData: any;\n  try {\n    taskData = JSON.parse(taskText);\n  } catch {\n    throw new Error(`volcengine non-JSON: ${truncate(taskText, 200)}`);\n  }\n  const taskId = taskData && taskData.id;\n  if (!taskId) throw new Error('volcengine task response missing id');\n\n  // Poll until succeeded/failed. Keep a hard cap, but make it long\n  // enough for real Seedance queues: fast t2v often returns in 30-120s,\n  // while i2v and busy-region t2v can exceed the old 6-minute ceiling.\n  const startedAt = Date.now();\n  const configuredMaxMs = Number(process.env.OD_VOLCENGINE_VIDEO_MAX_POLL_MS);\n  const maxMs =\n    Number.isFinite(configuredMaxMs) && configuredMaxMs >= 60_000\n      ? configuredMaxMs\n      : 12 * 60 * 1000;\n  let videoUrl: string | null = null;\n  let lastStatus = '';\n  // Emit a \"task accepted\" line right away so the agent's chat shows\n  // something within the first second instead of going silent for the\n  // full poll loop. cc's Bash tool considers a long-quiet pipe stuck","sourceCodeStart":1437,"sourceCodeEnd":1473,"githubUrl":"https://github.com/nexu-io/open-design/blob/5be4028344c2eb4c667c5a97bda8f750c5597ef7/apps/daemon/src/media/index.ts#L1437-L1473","documentation":"Thrown when `JSON.parse(taskText)` throws on the task-creation response. Volcengine (or an intermediary) returned a 2xx body that isn't JSON — typically an HTML error/gateway page — so the dispatcher surfaces up to 200 chars for diagnosis instead of an opaque parse error.","triggerScenarios":"2xx task-creation response that fails `JSON.parse`. Causes: a captive-portal/HTML auth wall, a Volcengine gateway returning an HTML 502/504 maintenance page with a 2xx status, or a `baseUrl` override pointing at a non-Ark host that serves HTML.","commonSituations":"(1) Behind a captive portal or corporate proxy injecting an HTML interstitial; (2) Volcengine regional outage surfacing an HTML status page with a 2xx status; (3) `baseUrl` mistyped to a path that serves HTML.","solutions":["Inspect the truncated body — HTML (`<html`/`<title>`) points to a gateway/proxy; fix routing or wait out the outage.","Verify `credentials.baseUrl` (or unset it to use the default `ark.cn-beijing.volces.com`).","If on a restricted network, ensure the Ark host is reachable and not redirected."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"// Reject HTML/gateway bodies before JSON.parse ever runs.\nfunction looksLikeArkJson(text: string): boolean {\n  const head = text.slice(0, 100).trim();\n  return head.startsWith('{') || head.startsWith('[');\n}\nif (!looksLikeArkJson(taskText)) {\n  throw new Error(`volcengine non-JSON (not an Ark body): ${truncate(taskText, 200)}`);\n}","typeGuard":null,"tryCatchPattern":"try { taskData = JSON.parse(taskText); }\ncatch { throw new Error(`volcengine non-JSON: ${truncate(taskText, 200)}`); }","preventionTips":["Confirm the daemon host can reach `ark.cn-beijing.volces.com` without an HTML redirect.","Avoid overriding `baseUrl` unless you control the target.","Log the response `Content-Type` header to catch gateway HTML early."],"tags":["volcengine","ark","seedance","json","network"],"backgroundTag":null,"analyzedSha":"5be4028344c2eb4c667c5a97bda8f750c5597ef7","analyzedAt":"2026-08-12T12:03:58.812Z","schemaVersion":2},"datasetVersion":"2026-08-12T18:17:37.767Z"}