{"record":{"id":"0003ef83800f4d7f","repo":"louislam/uptime-kuma","slug":"pagerduty-notification-failed-with-status-code-r","errorCode":null,"errorMessage":"PagerDuty notification failed with status code ${result.status}","messagePattern":"PagerDuty notification failed with status code (.+?)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"server/notification-providers/pagerduty.js","lineNumber":49,"sourceCode":"                return this.postNotification(notification, title, heartbeatJSON.msg, monitorJSON, \"trigger\");\n            }\n        } catch (error) {\n            this.throwGeneralAxiosError(error);\n        }\n    }\n\n    /**\n     * Check if result is successful, result code should be in range 2xx\n     * @param {object} result Axios response object\n     * @returns {void}\n     * @throws {Error} The status code is not in range 2xx\n     */\n    checkResult(result) {\n        if (result.status == null) {\n            throw new Error(\"PagerDuty notification failed with invalid response!\");\n        }\n        if (result.status < 200 || result.status >= 300) {\n            throw new Error(\"PagerDuty notification failed with status code \" + result.status);\n        }\n    }\n\n    /**\n     * Send the message\n     * @param {BeanModel} notification Message title\n     * @param {string} title Message title\n     * @param {string} body Message\n     * @param {object} monitorInfo Monitor details (For Up/Down only)\n     * @param {?string} eventAction Action event for PagerDuty (trigger, acknowledge, resolve)\n     * @returns {Promise<string>} Success message\n     */\n    async postNotification(notification, title, body, monitorInfo, eventAction = \"trigger\") {\n        let monitorUrl;\n        if (monitorInfo.type === \"port\") {\n            monitorUrl = monitorInfo.hostname;\n            if (monitorInfo.port) {\n                monitorUrl += \":\" + monitorInfo.port;","sourceCodeStart":31,"sourceCodeEnd":67,"githubUrl":"https://github.com/louislam/uptime-kuma/blob/6b5ea0155793e666666745fb8d6fef1e829543a2/server/notification-providers/pagerduty.js#L31-L67","documentation":"PagerDuty's checkResult(result) range guard: after confirming status is not null, it throws 'PagerDuty notification failed with status code <status>' for any status outside 200-299. This is the normal non-2xx failure path for the PagerDuty Events API v2 call (the surrounding code posts the PD event payload and passes the response here).","triggerScenarios":"PagerDuty returns 400 (malformed event payload / bad routing_key), 401/403 (bad auth), 429 (rate limited), 5xx (PagerDuty-side issue), or 422 (event action not permitted).","commonSituations":"Wrong or inactive routing_key/integration key for the PagerDuty service; event payload (dedup_key, event_action, severity) does not match the Events API v2 schema; PagerDuty incident limits hit.","solutions":["Confirm the PagerDuty integration/routing key is correct and the integration is active.","Validate the event payload against the Events API v2 schema (event_action, source, severity, dedup_key).","On 429, reduce notification frequency / back off.","On 4xx, log the response body to get PagerDuty's specific error details."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"if (!notification.pagerdutyIntegrationKey) {\n    throw new Error(\"pagerdutyIntegrationKey is required\");\n}","typeGuard":"/** @param {{status:number}} r */\nfunction is2xx(r) {\n    return typeof r.status === \"number\" && r.status >= 200 && r.status < 300;\n}","tryCatchPattern":"try {\n    const result = await axios.post(url, payload, config);\n    if (!is2xx(result)) {\n        throw new Error(`PagerDuty HTTP ${result.status}: ${JSON.stringify(result.data)}`);\n    }\n} catch (e) {\n    if (e.response?.status === 429) { /* back off */ }\n    if (e.response?.status >= 500) { /* retry */ }\n    throw e;\n}","preventionTips":["Validate the routing/integration key and payload schema before sending.","Retry 5xx and 429; do not retry 4xx (config) errors.","Log PagerDuty's response body for 4xx diagnosis."],"tags":["pagerduty","http","status-code","events-api"],"backgroundTag":null,"analyzedSha":"6b5ea0155793e666666745fb8d6fef1e829543a2","analyzedAt":"2026-08-12T23:42:12.959Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}