{"record":{"id":"431d2fc435751d6d","repo":"alibaba/nacos","slug":"http-response-status-431d2f","errorCode":null,"errorMessage":"HTTP ${response.status}","messagePattern":"HTTP \\$\\{response\\.status\\}","errorType":"http","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"console-ui-next/src/pages/promptDetail/index.tsx","lineNumber":530,"sourceCode":"    setDebugThinking('');\n    setDebugContent('');\n    setDebugError(null);\n\n    const ctxPath = window.location.pathname.replace(/\\/(next|legacy)(\\/.*)?$/, '/') || '/';\n    const url = `${window.location.origin}${ctxPath}v3/console/copilot/prompt/debug`;\n    const token = getAccessToken();\n\n    fetch(url, {\n      method: 'POST',\n      headers: {\n        'Content-Type': 'application/json',\n        Accept: 'text/event-stream',\n        ...(token ? { Authorization: `Bearer ${token}`, AccessToken: token } : {}),\n      },\n      body: JSON.stringify({ prompt: renderedPrompt, userInput }),\n    })\n      .then((response) => {\n        if (!response.ok) throw new Error(`HTTP ${response.status}`);\n        const reader = response.body!.getReader();\n        const decoder = new TextDecoder();\n        let buffer = '';\n        const read = (): Promise<void> =>\n          reader.read().then(({ done, value }) => {\n            if (done) { setDebugging(false); return; }\n            buffer += decoder.decode(value, { stream: true });\n            const lines = buffer.split('\\n');\n            buffer = lines.pop() || '';\n            lines.forEach((line) => {\n              if (line.startsWith('data:')) {\n                try {\n                  const data = JSON.parse(line.substring(5).trim());\n                  const typeStr = data.type?.code || data.type || 'CONTENT';\n                  if (typeStr === 'THINKING') setDebugThinking((p) => p + (data.chunk || ''));\n                  else if (typeStr === 'CONTENT') setDebugContent((p) => p + (data.chunk || ''));\n                  else if (typeStr === 'DONE' || data.done) setDebugging(false);\n                  else if (typeStr === 'error') { setDebugging(false); setDebugError(data.message || 'Error'); }","sourceCodeStart":512,"sourceCodeEnd":548,"githubUrl":"https://github.com/alibaba/nacos/blob/9b989acdf181d00898f2e8839257bb2b2a3cefe3/console-ui-next/src/pages/promptDetail/index.tsx#L512-L548","documentation":"Thrown by the prompt-detail page's SSE 'debug' handler (handleStartDebug) when the fetch response to POST /v3/console/copilot/prompt/debug returns a non-2xx status. The handler only checks response.ok and throws the bare status code, deferring all detail to the HTTP status. The endpoint is an SSE stream gated by @Secured(WRITE, AI, CONSOLE_API), so failures are typically auth- or config-related, not validation (validation failures are returned as 200 with an SSE error event).","triggerScenarios":"Calling the debug SSE endpoint with an expired/missing access token (401/403), hitting it without the AI/copolite module enabled (404), or a server-side AI model configuration error (500). The thrown string is literally 'HTTP ' + response.status.","commonSituations":"Session token expired while the prompt-detail page was open. Copilot/AI module not deployed in this Nacos build. User lacks CONSOLE_API WRITE permission on AI resources. Reverse proxy timing out the long SSE connection.","solutions":["Check the access token is present and valid (getAccessToken() returns a value); re-authenticate if expired.","Confirm the copilot module and an AI model backend are configured on the server.","Read the actual status: 401/403 → re-login / check permissions; 404 → endpoint not deployed; 500 → server logs.","Replace the bare throw with a status-aware message so the UI shows actionable text."],"exampleFix":"// before\n.then((response) => {\n  if (!response.ok) throw new Error(`HTTP ${response.status}`);\n\n// after\n.then(async (response) => {\n  if (!response.ok) {\n    const detail = await response.text().catch(() => '');\n    throw new Error(`Debug failed (${response.status}): ${detail || response.statusText}`);\n  }","handlingStrategy":"try-catch","validationCode":"function canStartDebug(token: string | null, userInput: string, renderedPrompt: string): boolean {\n  return !!token && !!userInput.trim() && !!renderedPrompt.trim();\n}","typeGuard":null,"tryCatchPattern":".then(async (response) => {\n  if (!response.ok) {\n    if (response.status === 401 || response.status === 403) { await reAuthenticate(); }\n    const body = await response.text().catch(() => response.statusText);\n    throw new Error(`Debug failed (${response.status}): ${body}`);\n  }\n  return response;\n}).catch((err) => { setDebugging(false); setDebugError(err.message); });","preventionTips":["Ensure the access token is fresh before starting a debug stream.","Confirm the copilot module and AI model are configured server-side.","Map HTTP status to user-facing guidance (401/403 re-login, 404 module missing, 500 server).","Pre-check renderedPrompt is non-empty to avoid sending an invalid request."],"tags":["sse","copilot","prompt-debug","typescript","network","react"],"backgroundTag":null,"analyzedSha":"9b989acdf181d00898f2e8839257bb2b2a3cefe3","analyzedAt":"2026-08-14T07:17:31.569Z","schemaVersion":2},"datasetVersion":"2026-08-14T10:17:34.591Z"}