{"record":{"id":"ba39c917a852b703","repo":"louislam/uptime-kuma","slug":"result-data-errmsg","errorCode":null,"errorMessage":"${result.data.errmsg}","messagePattern":"\\$\\{result\\.data\\.errmsg\\}","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"server/notification-providers/dingding.js","lineNumber":80,"sourceCode":"     */\n    async sendToDingDing(notification, params) {\n        let timestamp = Date.now();\n\n        let config = {\n            method: \"POST\",\n            headers: {\n                \"Content-Type\": \"application/json\",\n            },\n            url: `${notification.webHookUrl}&timestamp=${timestamp}&sign=${encodeURIComponent(this.sign(timestamp, notification.secretKey))}`,\n            data: JSON.stringify(params),\n        };\n        config = this.getAxiosConfigWithProxy(config);\n\n        let result = await axios(config);\n        if (result.data.errmsg === \"ok\") {\n            return true;\n        }\n        throw new Error(result.data.errmsg);\n    }\n\n    /**\n     * DingDing sign\n     * @param {Date} timestamp Timestamp of message\n     * @param {string} secretKey Secret key to sign data with\n     * @returns {string} Base64 encoded signature\n     */\n    sign(timestamp, secretKey) {\n        return Crypto.createHmac(\"sha256\", Buffer.from(secretKey, \"utf8\"))\n            .update(Buffer.from(`${timestamp}\\n${secretKey}`, \"utf8\"))\n            .digest(\"base64\");\n    }\n\n    /**\n     * Convert status constant to string\n     * @param {const} status The status constant\n     * @returns {string} Status","sourceCodeStart":62,"sourceCodeEnd":98,"githubUrl":"https://github.com/louislam/uptime-kuma/blob/6b5ea0155793e666666745fb8d6fef1e829543a2/server/notification-providers/dingding.js#L62-L98","documentation":"dingding.js:78-80. After signing and POSTing to the DingTalk webhook (URL + timestamp + HMAC-SHA256 signature), the provider expects result.data.errmsg === 'ok'. Any other value — typically 'token is invalid', 'sign not match', 'keyword is not contained', or 'message size exceed' — is thrown verbatim.","triggerScenarios":"Webhook URL/token removed or rotated (token is invalid), secretKey mismatch causing signature failure (sign not match), message body lacks the configured security keyword (keyword is not contained), or payload too large.","commonSituations":"DingTalk robot security setting 'custom keyword' enabled but the alert text does not contain it; secretKey copied with trailing whitespace breaking HMAC; webhook recreated in DingTalk producing a new URL/token not updated in Uptime Kuma.","solutions":["Map errmsg: 'token is invalid' → copy the current webhook URL; 'sign not match' → fix secretKey; 'keyword is not contained' → add the keyword to the alert template; size errors → shorten msg.","In DingTalk, re-open the robot config and copy BOTH the webhook URL and the secret.","Ensure secretKey has no leading/trailing whitespace when pasted.","If a custom keyword security policy is set, include that keyword in monitor alert messages."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"// Pre-validate DingTalk webhook URL + secret + security keyword\nfunction dingdingPreflight(notification, message) {\n    if (!/^https:\\/\\/oapi.dingtalk.com\\/robot\\/send\\?access_token=/.test(notification.webHookUrl || ''))\n        throw new Error('DingTalk webhook URL invalid');\n    if (!notification.secretKey) throw new Error('DingTalk secretKey missing');\n    if (notification.securityKeyword && !message.includes(notification.securityKeyword))\n        throw new Error('Alert text missing DingTalk security keyword');\n}","typeGuard":"function isDingdingOkPayload(d) { return d && typeof d === 'object' && d.errcode === 0 && d.errmsg === 'ok'; }","tryCatchPattern":"try { await provider.send(...); }\ncatch (e) {\n    if (/token is invalid/i.test(e.message)) log.error('DingTalk webhook token stale — recopy');\n    else if (/sign not match/i.test(e.message)) log.error('DingTalk secretKey mismatch — check whitespace');\n    else if (/keyword/i.test(e.message)) log.warn('Alert body missing configured DingTalk keyword');\n}","preventionTips":["Re-copy BOTH webhook URL and secret whenever the robot is recreated in DingTalk.","If using the keyword security policy, include that keyword in all alert templates."],"tags":["notification","dingding","dingtalk","webhook","signing"],"backgroundTag":null,"analyzedSha":"6b5ea0155793e666666745fb8d6fef1e829543a2","analyzedAt":"2026-08-12T23:42:12.959Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}