louislam/uptime-kuma · error · Error

VK API returned error ${response.data.error.error_code}: ${r

Error message

VK API returned error ${response.data.error.error_code}: ${response.data.error.error_msg}

What it means

Thrown by the VK provider when the VKontakte messages.send response contains an error object. The VK API returns HTTP 200 even on logical failures and embeds {error:{error_code,error_msg}} in the body; this branch surfaces that structured error with its official code and message.

Source

Thrown at server/notification-providers/vk.js:28

    async send(notification, msg, monitorJSON = null, heartbeatJSON = null) {
        const okMsg = "Sent Successfully.";
        const url = "https://api.vk.ru/method/messages.send";

        try {
            const data = new URLSearchParams({
                access_token: notification.vkAccessToken,
                v: notification.vkApiVersion,
                peer_id: notification.vkPeerId,
                message: msg,
                dont_parse_links: notification.vkDontParseLinks ? "1" : "0",
                random_id: String(Math.floor(Math.random() * 2147483647)),
            });

            const config = this.getAxiosConfigWithProxy({});
            const response = await axios.post(url, data, config);

            if (response.data?.error) {
                throw new Error(
                    `VK API returned error ${response.data.error.error_code}: ${response.data.error.error_msg}`
                );
            }

            if (typeof response.data?.response === "undefined") {
                throw new Error("Invalid VK API response");
            }

            return okMsg;
        } catch (error) {
            this.throwGeneralAxiosError(error);
        }
    }
}

module.exports = VK;

View on GitHub (pinned to 6b5ea01557)

Solutions

  1. Regenerate the user/group access_token in VK and update notification.vkAccessToken.
  2. Look up the numeric error_code at the VK API error reference; 900/901 means the bot lacks messaging permission for peer_id.
  3. Set vkApiVersion to a currently supported version (e.g. '5.199').
  4. If code 14 (captcha) or 6 (too fast), reduce notification frequency or solve the captcha interactively outside Uptime Kuma.
Defensive patterns

Strategy: try-catch

Validate before calling

// Surface configuration gaps before the request
if (!notification.vkAccessToken) throw new Error("VK access token is required");
if (!notification.vkPeerId) throw new Error("VK peer_id is required");
if (!notification.vkApiVersion) throw new Error("VK API version is required");

Type guard

/** True when the VK body carries the standard error envelope. */
function hasVkError(data) {
    return data != null && typeof data === "object" && data.error != null &&
        typeof data.error.error_code !== "undefined";
}

Try / catch

try {
    const response = await axios.post(url, data, config);
    if (response.data?.error) {
        throw new Error(`VK API returned error ${response.data.error.error_code}: ${response.data.error.error_msg}`);
    }
    if (typeof response.data?.response === "undefined") {
        throw new Error("Invalid VK API response");
    }
} catch (err) {
    this.throwGeneralAxiosError(err);
}

Prevention

When it happens

Trigger: Invalid or expired access_token (code 5), peer_id refers to a chat the bot cannot message (code 900, 901), rate limit (code 6), captcha required (code 14), or unsupported API version (vkApiVersion too old/new).

Common situations: Token revoked in VK settings, group chat the bot was kicked from, message longer than VK limits, or vkApiVersion left at a deprecated value.

Related errors


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