louislam/uptime-kuma · error · Error

Unexpected status code: ${result.status}

Error message

Unexpected status code: ${result.status}

What it means

Resend POSTs to https://api.resend.com/emails and treats only result.status === 200 as success; any other status throws `Unexpected status code: <status>`. Note this is stricter than a 2xx check, so a 201 (which Resend documents as the success code for /emails) would incorrectly trip this branch. The thrown Error is caught and re-processed via throwGeneralAxiosError.

Source

Thrown at server/notification-providers/resend.js:36

                },
            };
            config = this.getAxiosConfigWithProxy(config);
            const email = notification.resendFromEmail.trim();

            const fromName = notification.resendFromName?.trim() || "Uptime Kuma";
            let data = {
                from: `${fromName} <${email}>`,
                to: notification.resendToEmail,
                subject: notification.resendSubject || "Notification from Your Uptime Kuma",
                // supplied text directly instead of html
                text: msg,
            };

            let result = await axios.post("https://api.resend.com/emails", data, config);
            if (result.status === 200) {
                return okMsg;
            } else {
                throw new Error(`Unexpected status code: ${result.status}`);
            }
        } catch (error) {
            this.throwGeneralAxiosError(error);
        }
    }
}

module.exports = Resend;

View on GitHub (pinned to 6b5ea01557)

Solutions

  1. Confirm resendApiKey is set and valid (sent as Authorization: Bearer).
  2. Verify the From address is a verified domain/address in Resend.
  3. Widen the success check to accept the documented 2xx (especially 201) range rather than only 200.
  4. On 422, inspect Resend's response body for the invalid field.

Example fix

// before
let result = await axios.post("https://api.resend.com/emails", data, config);
if (result.status === 200) {
    return okMsg;
} else {
    throw new Error(`Unexpected status code: ${result.status}`);
}

// after - accept the documented 2xx success range
let result = await axios.post("https://api.resend.com/emails", data, config);
if (result.status >= 200 && result.status < 300) {
    return okMsg;
}
throw new Error(`Unexpected status code: ${result.status} ${JSON.stringify(result.data)}`);
Defensive patterns

Strategy: try-catch

Validate before calling

if (!notification.resendApiKey || !notification.resendToEmail) {
    throw new Error("resendApiKey and resendToEmail are required");
}

Type guard

/** @param {{status:number}} r */
function isResendSuccess(r) {
    return typeof r.status === "number" && r.status >= 200 && r.status < 300; // Resend returns 201
}

Try / catch

try {
    const result = await axios.post("https://api.resend.com/emails", data, config);
    if (isResendSuccess(result)) return okMsg;
    throw new Error(`Resend unexpected HTTP ${result.status}: ${JSON.stringify(result.data)}`);
} catch (e) {
    if (e.response?.status === 401 || e.response?.status === 403) {
        throw new Error("Resend auth failed - check resendApiKey");
    }
    throw e;
}

Prevention

When it happens

Trigger: Resend returns 201 Created (the documented success status) — this guard rejects it; 401/403 for a bad or missing resendApiKey (Authorization Bearer); 422 for invalid email parameters; 429 rate limit; 5xx.

Common situations: API key missing/expired; From address not verified in Resend; recipient address invalid; Resend genuinely returning 201 which the code misclassifies as failure.

Related errors


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