{"record":{"id":"7ad21d2c23ec2635","repo":"louislam/uptime-kuma","slug":"invalid-vk-api-response","errorCode":null,"errorMessage":"Invalid VK API response","messagePattern":"Invalid VK API response","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"server/notification-providers/vk.js","lineNumber":34,"sourceCode":"                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":16,"sourceCodeEnd":45,"githubUrl":"https://github.com/louislam/uptime-kuma/blob/6b5ea0155793e666666745fb8d6fef1e829543a2/server/notification-providers/vk.js#L16-L45","documentation":"Thrown by the VK provider when the response has neither an error object nor a response field. VK's contract is that messages.send returns either {error:...} on failure or {response:...} on success; the absence of both means the body shape was unexpected (HTML error page, gateway interstitial, empty object).","triggerScenarios":"A captive portal / proxy returning HTML instead of JSON, api.vk.ru routing through a CDN that returns an empty body on regional block, response truncated by a network device, or VK API schema change dropping the response wrapper.","commonSituations":"Server hosted in a region where VK is geo-blocked and the upstream returns an HTML block page, corporate proxy injecting a redirect, or a transient CDN error.","solutions":["From the Uptime Kuma host, curl -i https://api.vk.ru/method/messages.send with the same token to inspect the raw body and Content-Type.","If a proxy/CDN is intercepting, route via notification_proxy env var (see getAxiosConfigWithProxy) or change network egress.","Verify vkApiVersion is current — deprecated versions can return non-standard bodies.","If the body is consistently empty, escalate to VK API status / try a fallback notification channel."],"exampleFix":null,"handlingStrategy":"type-guard","validationCode":"// Reject non-JSON bodies early instead of failing on a missing 'response' field\nif (typeof response.data !== \"object\" || response.data === null) {\n    throw new Error(`Unexpected VK response content-type/body: ${typeof response.data}`);\n}","typeGuard":"/** True when data is a JSON object with either error or response. */\nfunction isVkEnvelope(data) {\n    return data && typeof data === \"object\" &&\n        (\"error\" in data || \"response\" in data);\n}","tryCatchPattern":"const response = await axios.post(url, data, config);\nif (!isVkEnvelope(response.data)) {\n    throw new Error(`Invalid VK API response: ${JSON.stringify(response.data).slice(0, 200)}`);\n}\nif (response.data.error) {\n    throw new Error(`VK API returned error ${response.data.error.error_code}: ${response.data.error.error_msg}`);\n}","preventionTips":["Egress-test api.vk.ru from the host to catch regional blocks.","Watch for proxy/CDN HTML interstitials in staging.","Log Content-Type alongside the body when triaging."],"tags":["vk","notification-provider","api-response","network","diagnostics"],"backgroundTag":null,"analyzedSha":"6b5ea0155793e666666745fb8d6fef1e829543a2","analyzedAt":"2026-08-12T23:42:12.959Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}