pot-app/pot-desktop · error · Error

Http Request Error Http Status: ${response.status} ${await r

Error message

Http Request Error
Http Status: ${response.status}
${await response.text()}

What it means

The ChatGLM (open.bigmodel.cn) translate service throws this when the POST to the chat/completions API returns a non-2xx status. It includes the status and the response body (which usually contains a JSON error object with code/message from the GLM API) so the developer can see the API-level failure reason.

Source

Thrown at src/services/translate/chatglm/index.jsx:58

    const body = {
        model: model,
        messages: promptList,
        stream: true,
        thinking: {
            type: "disabled",
        }
    };

    let result = '';
    try {
        const response = await fetch('https://open.bigmodel.cn/api/paas/v4/chat/completions', {
            method: 'POST',
            headers: headers,
            body: JSON.stringify(body),
        });
        if (!response.ok) {
            throw new Error(`Http Request Error\nHttp Status: ${response.status}\n${await response.text()}`);
        }

        let buffer = '';
        // Function to process the stream data
        const processChatStream = async (reader, decoder) => {
            while (true) {
                const { done, value } = await reader.read();
                if (done) break;

                // Convert binary data to string
                buffer += decoder.decode(value, { stream: true });
                
                // Process complete events
                const boundary = buffer.lastIndexOf('\n\n');
                if (boundary !== -1) {
                    const event = buffer.slice(0, boundary);
                    buffer = buffer.slice(boundary + 2);
                    const chunks = event.split('\n\n');

View on GitHub (pinned to 594d32ede9)

Solutions

  1. Read the JSON body in the message — the `code`/`message` fields from bigmodel.cn identify the exact cause (1002/1113 auth issues, 1301 quota, etc.).
  2. Verify the API key in the ChatGLM service config; regenerate it at open.bigmodel.cn if expired.
  3. Check account balance/quota on the bigmodel.cn console and top up if exhausted.
  4. Confirm the model name in the request body is one your key can access.

Example fix

// before
if (!response.ok) {
    throw new Error(`Http Request Error\nHttp Status: ${response.status}\n${await response.text()}`);
}
// after
if (response.status === 401) {
    throw new Error('ChatGLM API key invalid or expired — update it in settings');
}
if (!response.ok) {
    throw new Error(`Http Request Error\nHttp Status: ${response.status}\n${await response.text()}`);
}
Defensive patterns

Strategy: try-catch

Validate before calling

function validateChatGLMConfig(config) {
  return typeof config.apiKey === 'string' && config.apiKey.trim().length > 0 && /^([a-zA-Z0-9]+\.)?[a-zA-Z0-9]{16,}$/.test(config.apiKey.trim());
}
// call before issuing the request; also check navigator.onLine

Type guard

function isGlmErrorResponse(body) {
  return body != null && typeof body === 'object' && typeof body.code !== 'undefined' && typeof body.message === 'string';
}

Try / catch

try {
  const result = await chatglmTranslate(text, from, to);
} catch (e) {
  const msg = String(e.message);
  if (msg.includes(' 401') || msg.includes('1002') || msg.includes('1113')) {
    promptUserToFixApiKey(); // invalid/expired key
  } else if (msg.includes('1301') || msg.includes(' 429')) {
    promptUserToTopUpOrWait(); // quota/rate limit
  } else {
    throw e;
  }
}

Prevention

When it happens

Trigger: Calling the ChatGLM translate flow when the POST https://open.bigmodel.cn/api/paas/v4/chat/completions fails: invalid/expired API key (401), insufficient balance/quota (429 or 4xx with quota code), malformed request body, or model name not available to the account.

Common situations: User pasted a wrong or revoked API key into the ChatGLM config, the account ran out of tokens/credits, the API key was regenerated server-side, or the chosen model (e.g. glm-4) was deprecated or not entitled for the key.

Related errors


AI-assisted analysis of pot-app/pot-desktop@594d32ede9 (2026-09-02). Data as JSON: /api/errors/5cbfb6fe309d1217. Report an issue: GitHub.