{"record":{"id":"44ec544cdced7595","repo":"alibaba/nacos","slug":"http-error-status-response-status-44ec54","errorCode":null,"errorMessage":"HTTP error! status: ${response.status}","messagePattern":"HTTP error! status: (.+?)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"console-ui/src/pages/AI/PromptOptimizeDialog/PromptOptimizeDialog.js","lineNumber":122,"sourceCode":"      accessToken = tokenObj.accessToken || '';\n    } catch (e) {\n      // eslint-disable-next-line no-console\n      console.error('Failed to parse token:', e);\n    }\n\n    fetch(url, {\n      method: 'POST',\n      headers: {\n        'Content-Type': 'application/json',\n        Accept: 'text/event-stream',\n        ...(accessToken ? { Authorization: `Bearer ${accessToken}` } : {}),\n        ...(accessToken ? { AccessToken: accessToken } : {}),\n      },\n      body: JSON.stringify(payload),\n    })\n      .then(response => {\n        if (!response.ok) {\n          throw new Error(`HTTP error! status: ${response.status}`);\n        }\n\n        const reader = response.body.getReader();\n        const decoder = new TextDecoder();\n        let buffer = '';\n\n        const readStream = () => {\n          reader\n            .read()\n            .then(({ done, value }) => {\n              if (done) {\n                this.setState(prevState => ({\n                  streaming: false,\n                  loading: false,\n                  optimizedPrompt: prevState.streamContent || null,\n                }));\n                return;\n              }","sourceCodeStart":104,"sourceCodeEnd":140,"githubUrl":"https://github.com/alibaba/nacos/blob/9b989acdf181d00898f2e8839257bb2b2a3cefe3/console-ui/src/pages/AI/PromptOptimizeDialog/PromptOptimizeDialog.js#L104-L140","documentation":"Thrown by the Prompt Optimize dialog when the fetch to the prompt-optimize SSE endpoint returns a non-2xx status. This is the streaming optimization flow that sends a prompt to an LLM for improvement; a failed HTTP response aborts the stream before any content is read.","triggerScenarios":"Clicking optimize in the Prompt Optimize dialog and the server rejects the request. Causes: 401/403 (token invalid), 400 (empty or invalid prompt), 404 (optimize endpoint not registered), 500/502 (LLM provider or AI pipeline failure).","commonSituations":"Session token expired, AI optimize pipeline not configured on the server, LLM provider API key missing/invalid, or the prompt payload exceeds server limits.","solutions":["Read the embedded status: 401/403 -> re-login; 400 -> supply valid prompt text; 5xx -> check server AI pipeline and LLM provider config.","Ensure the access token parsed from the session is non-empty before opening the dialog.","Confirm the server's prompt-optimize endpoint and the backing model provider are configured and reachable.","Inspect the failed POST response body in the browser network panel for the detailed server error."],"exampleFix":"// before\nif (!response.ok) {\n  throw new Error(`HTTP error! status: ${response.status}`);\n}\n\n// after\nif (!response.ok) {\n  const body = await response.text();\n  throw new Error(`Prompt optimize failed (${response.status}): ${body}`);\n}","handlingStrategy":"try-catch","validationCode":"function ensureToken(token) {\n  let accessToken = '';\n  try { accessToken = JSON.parse(token).accessToken || ''; } catch {}\n  if (!accessToken) throw new Error('Missing access token; please re-login');\n  return accessToken;\n}","typeGuard":null,"tryCatchPattern":".then(async response => {\n  if (!response.ok) {\n    const body = await response.text();\n    this.setState({ streaming: false, loading: false, optimizeError: `Optimize failed (${response.status}): ${body}` });\n    return;\n  }\n  // ...read stream\n}).catch(error => this.setState({ streaming: false, loading: false, optimizeError: error.message }));","preventionTips":["Validate the prompt input is non-empty before optimizing.","Refresh the session token before opening the dialog.","Verify the server's optimize endpoint and LLM provider are configured."],"tags":["network","sse","prompt","optimize","frontend","auth"],"backgroundTag":null,"analyzedSha":"9b989acdf181d00898f2e8839257bb2b2a3cefe3","analyzedAt":"2026-08-14T07:17:31.569Z","schemaVersion":2},"datasetVersion":"2026-08-14T10:17:34.591Z"}