{"record":{"id":"5a22a79318392d60","repo":"louislam/uptime-kuma","slug":"data-error-string-json-stringify-data","errorCode":null,"errorMessage":"${data?.error_string || JSON.stringify(data)}","messagePattern":"\\$\\{data\\?\\.error_string \\|\\| JSON\\.stringify\\(data\\)\\}","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"server/notification-providers/bearsms.js","lineNumber":44,"sourceCode":"                params.append(\"from\", notification.bearsmsSenderId);\n            }\n\n            // Non-GSM text (e.g. Hebrew) must be flagged as unicode\n            if (/[^\\x00-\\x7F]/.test(cleanMsg)) {\n                params.append(\"unicode\", \"1\");\n            }\n\n            const url = `https://app.bearsms.com/index.php?${params.toString()}`;\n            let config = this.getAxiosConfigWithProxy({});\n            const response = await axios.get(url, config);\n\n            // BearSMS responds with HTTP 200 even on failure.\n            // Failure: {\"status\":\"ERR\",\"error\":\"100\",\"error_string\":\"authentication failed\"}\n            // Success: {\"data\":[{\"status\":\"OK\",\"error\":\"0\",\"smslog_id\":\"...\"}],\"error_string\":null}\n            const data = response.data;\n            const results = Array.isArray(data?.data) ? data.data : [];\n            if (data?.status === \"ERR\" || data?.error_string || !results.some((r) => r.status === \"OK\")) {\n                throw new Error(data?.error_string || JSON.stringify(data));\n            }\n\n            return okMsg;\n        } catch (error) {\n            this.throwGeneralAxiosError(error);\n        }\n    }\n}\n\nmodule.exports = BearSMS;\n","sourceCodeStart":26,"sourceCodeEnd":55,"githubUrl":"https://github.com/louislam/uptime-kuma/blob/6b5ea0155793e666666745fb8d6fef1e829543a2/server/notification-providers/bearsms.js#L26-L55","documentation":"bearsms.js:32-45. BearSMS returns HTTP 200 even on failure and signals errors in the JSON body. The provider throws when: data.status === 'ERR', data.error_string is truthy, OR none of the per-recipient results contain status:'OK'. The message is error_string when present, else the whole JSON dump.","triggerScenarios":"Wrong username/password ('authentication failed'), insufficient credits, an invalid destination number, or a partial failure where every recipient returned a non-OK status.","commonSituations":"BearSMS API credentials rotated; account out of SMS credits; destination numbers not in the international format BearSMS requires; recipient list all marked invalid by the gateway.","solutions":["Read error_string — 'authentication failed' → fix user/pass; credit errors → top up; number errors → fix format.","Log into the BearSMS dashboard to confirm account balance and API credentials.","Reformat destination numbers to the required international format.","If error_string is null but results are non-OK, inspect the dumped JSON for per-recipient error codes."],"exampleFix":null,"handlingStrategy":"type-guard","validationCode":"// Pre-validate credentials + destination format\nfunction bearPreflight(notification, phone) {\n    if (!notification.username || !notification.password) throw new Error('BearSMS credentials missing');\n    if (!/^\\+?[1-9]\\d{6,14}$/.test(phone)) throw new Error('Invalid BearSMS destination');\n}","typeGuard":"function isBearSmsErrorBody(d) { return d && typeof d === 'object' && d.status === 'ERR'; }","tryCatchPattern":"try { await provider.send(...); }\ncatch (e) {\n    if (/authentication failed/i.test(e.message)) log.error('BearSMS auth — fix user/pass');\n    else if (/credit|balance/i.test(e.message)) heartbeat.status = PENDING;\n}","preventionTips":["Monitor BearSMS credit balance alongside the notification provider.","Keep destination numbers in the international format the gateway requires."],"tags":["notification","sms","bearsms","api","credentials"],"backgroundTag":null,"analyzedSha":"6b5ea0155793e666666745fb8d6fef1e829543a2","analyzedAt":"2026-08-12T23:42:12.959Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}