{"record":{"id":"ecab2e186470aeb9","repo":"bytedance/deer-flow","slug":"http-response-status-text","errorCode":null,"errorMessage":"HTTP ${response.status}: ${text}","messagePattern":"HTTP (.+?): (.+?)","errorType":"http","errorClass":null,"httpStatus":null,"severity":"error","filePath":"skills/public/chart-visualization/scripts/generate.js","lineNumber":56,"sourceCode":"  );\n}\n\nfunction getServiceIdentifier() {\n  return process.env.SERVICE_ID;\n}\n\nasync function httpPost(url, payload) {\n  const response = await fetch(url, {\n    method: \"POST\",\n    headers: {\n      \"Content-Type\": \"application/json\",\n    },\n    body: JSON.stringify(payload),\n  });\n\n  if (!response.ok) {\n    const text = await response.text();\n    throw new Error(`HTTP ${response.status}: ${text}`);\n  }\n\n  return response.json();\n}\n\nasync function generateChartUrl(chartType, options) {\n  const url = getVisRequestServer();\n  const payload = {\n    type: chartType,\n    source: \"chart-visualization-creator\",\n    ...options,\n  };\n\n  const data = await httpPost(url, payload);\n\n  if (!data.success) {\n    throw new Error(data.errorMessage || \"Unknown error\");\n  }","sourceCodeStart":38,"sourceCodeEnd":74,"githubUrl":"https://github.com/bytedance/deer-flow/blob/1dd6ba1acb03700589994b0366c5d1c7d05e2eff/skills/public/chart-visualization/scripts/generate.js#L38-L74","documentation":"httpPost in the chart-visualization skill's generate.js wraps fetch(POST JSON) and throws `HTTP <status>: <body>` when the remote chart service (getVisRequestServer()) answers non-ok. The body text is inlined so the caller sees the service's own error output.","triggerScenarios":"The configured vis-request server returns 4xx (bad payload for the chart type, missing serviceId for maps) or 5xx (service down). Also DNS/connect failures surface as fetch rejections, but any HTTP-level failure produces this formatted error.","commonSituations":"VIS_REQUEST_SERVER env var unset or pointing at a wrong/unreachable deployment (leading to a proxy 404/502 HTML body inlined into the message), the chart service API changing its contract, or a quota/rate-limit response from the hosted chart service.","solutions":["Read the status and body in the thrown message: 401/403 means credentials/quota, 404/502 usually a wrong VIS_REQUEST_SERVER URL, 4xx with JSON a payload-contract issue.","Verify getVisRequestServer() resolves to the intended service (check the env/config it reads) and curl it with a minimal payload.","If the service API changed, update the payload builders (generateChartUrl / generateMap) to the new contract.","For quota errors, add backoff/retry or switch to a self-hosted instance."],"exampleFix":"// before: throws raw HTTP text (often huge HTML)\nthrow new Error(`HTTP ${response.status}: ${text}`);\n\n// after: truncate and name the endpoint\nthrow new Error(`Chart service ${url} failed (${response.status}): ${text.slice(0, 300)}`);","handlingStrategy":"try-catch","validationCode":"// Pre-flight the endpoint cheaply before posting the real payload:\n// const probe = await fetch(getVisRequestServer(), { method: 'OPTIONS' });\n// if (!probe.ok && probe.status !== 404) fail fast with a clear message.","typeGuard":null,"tryCatchPattern":"try { const url = await generateChartUrl(type, opts); } catch (e) { console.error('chart service failure:', e.message); throw new Error(`Chart generation unavailable (${extractStatus(e.message)}); check VIS_REQUEST_SERVER`); }","preventionTips":["Validate VIS_REQUEST_SERVER at script start and fail with an explicit message if unset/unreachable.","Cap inlined error bodies so HTML error pages don't flood output.","Add retry with backoff for 5xx/502 from the chart service."],"tags":["skills","chart","http","external-service","node"],"backgroundTag":null,"analyzedSha":"1dd6ba1acb03700589994b0366c5d1c7d05e2eff","analyzedAt":"2026-08-14T21:20:34.804Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}