louislam/uptime-kuma · error · Error

OneChat API Error: ${errorMessage}

Error message

OneChat API Error: ${errorMessage}

What it means

OneChat's catch block inspects error.response: if present it throws `OneChat API Error: ${error.response.data?.message || 'Unknown API error occurred.'}`; otherwise it delegates to throwGeneralAxiosError. So this specific message fires only when the OneChat API actually responded (axios rejected with a response) and the body either has a `message` field or not.

Source

Thrown at server/notification-providers/onechat.js:62

                const upMessage = {
                    to: notification.recieverId,
                    bot_id: notification.botId,
                    type: "text",
                    message: `UptimeKuma Alert:
[🟢 Up]
Name: ${monitorJSON["name"]}
${heartbeatJSON["msg"]}
Time (${heartbeatJSON["timezone"]}): ${heartbeatJSON["localDateTime"]}`,
                };
                await axios.post(url, upMessage, config);
            }

            return okMsg;
        } catch (error) {
            // Handle errors and throw a descriptive message
            if (error.response) {
                const errorMessage = error.response.data?.message || "Unknown API error occurred.";
                throw new Error(`OneChat API Error: ${errorMessage}`);
            } else {
                this.throwGeneralAxiosError(error);
            }
        }
    }
}

module.exports = OneChat;

View on GitHub (pinned to 6b5ea01557)

Solutions

  1. Verify the OneChat access token and the chat id / endpoint URL in the notification config.
  2. Log error.response.status and the full error.response.data once to see OneChat's actual error envelope.
  3. If OneChat renamed the field, update the extraction (e.g. data.error or data.detail) to match.
  4. Handle 429 by backing off / reducing notification volume.

Example fix

// before
const errorMessage = error.response.data?.message || "Unknown API error occurred.";
throw new Error(`OneChat API Error: ${errorMessage}`);

// after - include HTTP status and raw body for diagnosability
const status = error.response.status;
const body = error.response.data;
const errorMessage = body?.message || body?.error || JSON.stringify(body);
throw new Error(`OneChat API Error (HTTP ${status}): ${errorMessage}`);
Defensive patterns

Strategy: try-catch

Validate before calling

if (!notification.onechatToken || !notification.onechatUrl) {
    throw new Error("OneChat token and endpoint URL are required");
}

Try / catch

try {
    await axios.post(url, payload, config);
} catch (error) {
    if (error.response) {
        const body = error.response.data;
        const msg = body?.message || body?.error || JSON.stringify(body);
        throw new Error(`OneChat API HTTP ${error.response.status}: ${msg}`);
    }
    throw new Error(`OneChat transport error: ${error.code || error.message}`);
}

Prevention

When it happens

Trigger: POST to the OneChat url returns non-2xx with a JSON body containing message (e.g. invalid token -> 401 with message, rate limit -> 429 with message, bad chat id -> 400), or returns non-2xx with a body lacking `message` (surfaces as 'Unknown API error occurred.').

Common situations: OneChat API key/token wrong or expired; recipient chat id invalid; OneChat rate limiting; OneChat API changed its error envelope so data.message is no longer present.

Related errors


AI-assisted analysis of louislam/uptime-kuma@6b5ea01557 (2026-08-12). Data as JSON: /api/errors/d1962fa2d4f65979. Report an issue: GitHub.