{"record":{"id":"828644172098f713","repo":"louislam/uptime-kuma","slug":"unexpected-status-code-result-status-828644","errorCode":null,"errorMessage":"Unexpected status code: ${result.status}","messagePattern":"Unexpected status code: (.+?)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"server/notification-providers/resend.js","lineNumber":36,"sourceCode":"                },\n            };\n            config = this.getAxiosConfigWithProxy(config);\n            const email = notification.resendFromEmail.trim();\n\n            const fromName = notification.resendFromName?.trim() || \"Uptime Kuma\";\n            let data = {\n                from: `${fromName} <${email}>`,\n                to: notification.resendToEmail,\n                subject: notification.resendSubject || \"Notification from Your Uptime Kuma\",\n                // supplied text directly instead of html\n                text: msg,\n            };\n\n            let result = await axios.post(\"https://api.resend.com/emails\", data, config);\n            if (result.status === 200) {\n                return okMsg;\n            } else {\n                throw new Error(`Unexpected status code: ${result.status}`);\n            }\n        } catch (error) {\n            this.throwGeneralAxiosError(error);\n        }\n    }\n}\n\nmodule.exports = Resend;\n","sourceCodeStart":18,"sourceCodeEnd":45,"githubUrl":"https://github.com/louislam/uptime-kuma/blob/6b5ea0155793e666666745fb8d6fef1e829543a2/server/notification-providers/resend.js#L18-L45","documentation":"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.","triggerScenarios":"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.","commonSituations":"API key missing/expired; From address not verified in Resend; recipient address invalid; Resend genuinely returning 201 which the code misclassifies as failure.","solutions":["Confirm resendApiKey is set and valid (sent as Authorization: Bearer).","Verify the From address is a verified domain/address in Resend.","Widen the success check to accept the documented 2xx (especially 201) range rather than only 200.","On 422, inspect Resend's response body for the invalid field."],"exampleFix":"// before\nlet result = await axios.post(\"https://api.resend.com/emails\", data, config);\nif (result.status === 200) {\n    return okMsg;\n} else {\n    throw new Error(`Unexpected status code: ${result.status}`);\n}\n\n// after - accept the documented 2xx success range\nlet result = await axios.post(\"https://api.resend.com/emails\", data, config);\nif (result.status >= 200 && result.status < 300) {\n    return okMsg;\n}\nthrow new Error(`Unexpected status code: ${result.status} ${JSON.stringify(result.data)}`);","handlingStrategy":"try-catch","validationCode":"if (!notification.resendApiKey || !notification.resendToEmail) {\n    throw new Error(\"resendApiKey and resendToEmail are required\");\n}","typeGuard":"/** @param {{status:number}} r */\nfunction isResendSuccess(r) {\n    return typeof r.status === \"number\" && r.status >= 200 && r.status < 300; // Resend returns 201\n}","tryCatchPattern":"try {\n    const result = await axios.post(\"https://api.resend.com/emails\", data, config);\n    if (isResendSuccess(result)) return okMsg;\n    throw new Error(`Resend unexpected HTTP ${result.status}: ${JSON.stringify(result.data)}`);\n} catch (e) {\n    if (e.response?.status === 401 || e.response?.status === 403) {\n        throw new Error(\"Resend auth failed - check resendApiKey\");\n    }\n    throw e;\n}","preventionTips":["Accept the full 2xx range (Resend documents 201) instead of only 200.","Verify the From address is approved in Resend.","Retry on 429/5xx; fix config on 4xx."],"tags":["network","http","resend","email","status-code"],"backgroundTag":null,"analyzedSha":"6b5ea0155793e666666745fb8d6fef1e829543a2","analyzedAt":"2026-08-12T23:42:12.959Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}