alibaba/nacos · error · Error

HTTP ${response.status}

Error message

HTTP ${response.status}

What it means

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).

Source

Thrown at console-ui-next/src/pages/promptDetail/index.tsx:530

    setDebugThinking('');
    setDebugContent('');
    setDebugError(null);

    const ctxPath = window.location.pathname.replace(/\/(next|legacy)(\/.*)?$/, '/') || '/';
    const url = `${window.location.origin}${ctxPath}v3/console/copilot/prompt/debug`;
    const token = getAccessToken();

    fetch(url, {
      method: 'POST',
      headers: {
        'Content-Type': 'application/json',
        Accept: 'text/event-stream',
        ...(token ? { Authorization: `Bearer ${token}`, AccessToken: token } : {}),
      },
      body: JSON.stringify({ prompt: renderedPrompt, userInput }),
    })
      .then((response) => {
        if (!response.ok) throw new Error(`HTTP ${response.status}`);
        const reader = response.body!.getReader();
        const decoder = new TextDecoder();
        let buffer = '';
        const read = (): Promise<void> =>
          reader.read().then(({ done, value }) => {
            if (done) { setDebugging(false); return; }
            buffer += decoder.decode(value, { stream: true });
            const lines = buffer.split('\n');
            buffer = lines.pop() || '';
            lines.forEach((line) => {
              if (line.startsWith('data:')) {
                try {
                  const data = JSON.parse(line.substring(5).trim());
                  const typeStr = data.type?.code || data.type || 'CONTENT';
                  if (typeStr === 'THINKING') setDebugThinking((p) => p + (data.chunk || ''));
                  else if (typeStr === 'CONTENT') setDebugContent((p) => p + (data.chunk || ''));
                  else if (typeStr === 'DONE' || data.done) setDebugging(false);
                  else if (typeStr === 'error') { setDebugging(false); setDebugError(data.message || 'Error'); }

View on GitHub (pinned to 9b989acdf1)

Solutions

  1. Check the access token is present and valid (getAccessToken() returns a value); re-authenticate if expired.
  2. Confirm the copilot module and an AI model backend are configured on the server.
  3. Read the actual status: 401/403 → re-login / check permissions; 404 → endpoint not deployed; 500 → server logs.
  4. Replace the bare throw with a status-aware message so the UI shows actionable text.

Example fix

// before
.then((response) => {
  if (!response.ok) throw new Error(`HTTP ${response.status}`);

// after
.then(async (response) => {
  if (!response.ok) {
    const detail = await response.text().catch(() => '');
    throw new Error(`Debug failed (${response.status}): ${detail || response.statusText}`);
  }
Defensive patterns

Strategy: try-catch

Validate before calling

function canStartDebug(token: string | null, userInput: string, renderedPrompt: string): boolean {
  return !!token && !!userInput.trim() && !!renderedPrompt.trim();
}

Try / catch

.then(async (response) => {
  if (!response.ok) {
    if (response.status === 401 || response.status === 403) { await reAuthenticate(); }
    const body = await response.text().catch(() => response.statusText);
    throw new Error(`Debug failed (${response.status}): ${body}`);
  }
  return response;
}).catch((err) => { setDebugging(false); setDebugError(err.message); });

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Related errors


AI-assisted analysis of alibaba/nacos@9b989acdf1 (2026-08-14). Data as JSON: /api/errors/431d2fc435751d6d. Report an issue: GitHub.