{"record":{"id":"0b3da5961889e986","repo":"louislam/uptime-kuma","slug":"vk-api-returned-error-response-data-error-error","errorCode":null,"errorMessage":"VK API returned error ${response.data.error.error_code}: ${response.data.error.error_msg}","messagePattern":"VK API returned error (.+?): (.+?)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"server/notification-providers/vk.js","lineNumber":28,"sourceCode":"    async send(notification, msg, monitorJSON = null, heartbeatJSON = null) {\n        const okMsg = \"Sent Successfully.\";\n        const url = \"https://api.vk.ru/method/messages.send\";\n\n        try {\n            const data = new URLSearchParams({\n                access_token: notification.vkAccessToken,\n                v: notification.vkApiVersion,\n                peer_id: notification.vkPeerId,\n                message: msg,\n                dont_parse_links: notification.vkDontParseLinks ? \"1\" : \"0\",\n                random_id: String(Math.floor(Math.random() * 2147483647)),\n            });\n\n            const config = this.getAxiosConfigWithProxy({});\n            const response = await axios.post(url, data, config);\n\n            if (response.data?.error) {\n                throw new Error(\n                    `VK API returned error ${response.data.error.error_code}: ${response.data.error.error_msg}`\n                );\n            }\n\n            if (typeof response.data?.response === \"undefined\") {\n                throw new Error(\"Invalid VK API response\");\n            }\n\n            return okMsg;\n        } catch (error) {\n            this.throwGeneralAxiosError(error);\n        }\n    }\n}\n\nmodule.exports = VK;\n","sourceCodeStart":10,"sourceCodeEnd":45,"githubUrl":"https://github.com/louislam/uptime-kuma/blob/6b5ea0155793e666666745fb8d6fef1e829543a2/server/notification-providers/vk.js#L10-L45","documentation":"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.","triggerScenarios":"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).","commonSituations":"Token revoked in VK settings, group chat the bot was kicked from, message longer than VK limits, or vkApiVersion left at a deprecated value.","solutions":["Regenerate the user/group access_token in VK and update notification.vkAccessToken.","Look up the numeric error_code at the VK API error reference; 900/901 means the bot lacks messaging permission for peer_id.","Set vkApiVersion to a currently supported version (e.g. '5.199').","If code 14 (captcha) or 6 (too fast), reduce notification frequency or solve the captcha interactively outside Uptime Kuma."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"// Surface configuration gaps before the request\nif (!notification.vkAccessToken) throw new Error(\"VK access token is required\");\nif (!notification.vkPeerId) throw new Error(\"VK peer_id is required\");\nif (!notification.vkApiVersion) throw new Error(\"VK API version is required\");","typeGuard":"/** True when the VK body carries the standard error envelope. */\nfunction hasVkError(data) {\n    return data != null && typeof data === \"object\" && data.error != null &&\n        typeof data.error.error_code !== \"undefined\";\n}","tryCatchPattern":"try {\n    const response = await axios.post(url, data, config);\n    if (response.data?.error) {\n        throw new Error(`VK API returned error ${response.data.error.error_code}: ${response.data.error.error_msg}`);\n    }\n    if (typeof response.data?.response === \"undefined\") {\n        throw new Error(\"Invalid VK API response\");\n    }\n} catch (err) {\n    this.throwGeneralAxiosError(err);\n}","preventionTips":["Treat token expiry as expected — rotate on a schedule.","Keep vkApiVersion current with VK's published versions.","Confirm the bot has message permission for peer_id before relying on it."],"tags":["vk","notification-provider","api-error","auth","config"],"backgroundTag":null,"analyzedSha":"6b5ea0155793e666666745fb8d6fef1e829543a2","analyzedAt":"2026-08-12T23:42:12.959Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}