alibaba/nacos · error · Error

HTTP error! status: ${response.status}

Error message

HTTP error! status: ${response.status}

What it means

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.

Source

Thrown at console-ui/src/pages/AI/PromptOptimizeDialog/PromptOptimizeDialog.js:122

      accessToken = tokenObj.accessToken || '';
    } catch (e) {
      // eslint-disable-next-line no-console
      console.error('Failed to parse token:', e);
    }

    fetch(url, {
      method: 'POST',
      headers: {
        'Content-Type': 'application/json',
        Accept: 'text/event-stream',
        ...(accessToken ? { Authorization: `Bearer ${accessToken}` } : {}),
        ...(accessToken ? { AccessToken: accessToken } : {}),
      },
      body: JSON.stringify(payload),
    })
      .then(response => {
        if (!response.ok) {
          throw new Error(`HTTP error! status: ${response.status}`);
        }

        const reader = response.body.getReader();
        const decoder = new TextDecoder();
        let buffer = '';

        const readStream = () => {
          reader
            .read()
            .then(({ done, value }) => {
              if (done) {
                this.setState(prevState => ({
                  streaming: false,
                  loading: false,
                  optimizedPrompt: prevState.streamContent || null,
                }));
                return;
              }

View on GitHub (pinned to 9b989acdf1)

Solutions

  1. Read the embedded status: 401/403 -> re-login; 400 -> supply valid prompt text; 5xx -> check server AI pipeline and LLM provider config.
  2. Ensure the access token parsed from the session is non-empty before opening the dialog.
  3. Confirm the server's prompt-optimize endpoint and the backing model provider are configured and reachable.
  4. Inspect the failed POST response body in the browser network panel for the detailed server error.

Example fix

// before
if (!response.ok) {
  throw new Error(`HTTP error! status: ${response.status}`);
}

// after
if (!response.ok) {
  const body = await response.text();
  throw new Error(`Prompt optimize failed (${response.status}): ${body}`);
}
Defensive patterns

Strategy: try-catch

Validate before calling

function ensureToken(token) {
  let accessToken = '';
  try { accessToken = JSON.parse(token).accessToken || ''; } catch {}
  if (!accessToken) throw new Error('Missing access token; please re-login');
  return accessToken;
}

Try / catch

.then(async response => {
  if (!response.ok) {
    const body = await response.text();
    this.setState({ streaming: false, loading: false, optimizeError: `Optimize failed (${response.status}): ${body}` });
    return;
  }
  // ...read stream
}).catch(error => this.setState({ streaming: false, loading: false, optimizeError: error.message }));

Prevention

When it happens

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

Common situations: Session token expired, AI optimize pipeline not configured on the server, LLM provider API key missing/invalid, or the prompt payload exceeds server limits.

Related errors


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