louislam/uptime-kuma · error · Error

Invalid VK API response

Error message

Invalid VK API response

What it means

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).

Source

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

                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. 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.
  2. If a proxy/CDN is intercepting, route via notification_proxy env var (see getAxiosConfigWithProxy) or change network egress.
  3. Verify vkApiVersion is current — deprecated versions can return non-standard bodies.
  4. If the body is consistently empty, escalate to VK API status / try a fallback notification channel.
Defensive patterns

Strategy: type-guard

Validate before calling

// Reject non-JSON bodies early instead of failing on a missing 'response' field
if (typeof response.data !== "object" || response.data === null) {
    throw new Error(`Unexpected VK response content-type/body: ${typeof response.data}`);
}

Type guard

/** True when data is a JSON object with either error or response. */
function isVkEnvelope(data) {
    return data && typeof data === "object" &&
        ("error" in data || "response" in data);
}

Try / catch

const response = await axios.post(url, data, config);
if (!isVkEnvelope(response.data)) {
    throw new Error(`Invalid VK API response: ${JSON.stringify(response.data).slice(0, 200)}`);
}
if (response.data.error) {
    throw new Error(`VK API returned error ${response.data.error.error_code}: ${response.data.error.error_msg}`);
}

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Related errors


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