Telegram notification fail to send alert with error "Cannot read properties of undefined (reading 'data')" #1007

Closed
opened 2026-02-28 02:06:58 -05:00 by deekerman · 8 comments
Owner

Originally created by @a2940uw on GitHub (Apr 20, 2022).

⚠️ Please verify that this bug has NOT been raised before.

  • I checked and didn't find similar issue

🛡️ Security Policy

📝 Describe your problem

Hi, I have to setup Telegram notification and fill the required Bot token and Chat ID correctly, but the Test was fail and prompted "Cannot read properties of undefined (reading 'data'), my network require to use proxy for internet access, the uptime-kuma hosts already have proxy setting and internet access is ok, I don't know this error is related to internet access or other issue.

🐻 Uptime-Kuma Version

1.14.0

💻 Operating System and Arch

Raspberry Pi OS 11 (bullseye)

🌐 Browser

Chrome

🐋 Docker Version

Docker version 20.10.14, build a224086

🟩 NodeJS Version

No response

Originally created by @a2940uw on GitHub (Apr 20, 2022). ### ⚠️ Please verify that this bug has NOT been raised before. - [X] I checked and didn't find similar issue ### 🛡️ Security Policy - [X] I agree to have read this project [Security Policy](https://github.com/louislam/uptime-kuma/security/policy) ### 📝 Describe your problem Hi, I have to setup Telegram notification and fill the required Bot token and Chat ID correctly, but the Test was fail and prompted "Cannot read properties of undefined (reading 'data'), my network require to use proxy for internet access, the uptime-kuma hosts already have proxy setting and internet access is ok, I don't know this error is related to internet access or other issue. ### 🐻 Uptime-Kuma Version 1.14.0 ### 💻 Operating System and Arch Raspberry Pi OS 11 (bullseye) ### 🌐 Browser Chrome ### 🐋 Docker Version Docker version 20.10.14, build a224086 ### 🟩 NodeJS Version _No response_
deekerman 2026-02-28 02:06:58 -05:00
  • closed this issue
  • added the
    Stale
    help
    labels
Author
Owner

@louislam commented on GitHub (Apr 21, 2022):

Proxy is not support for notifications.

@louislam commented on GitHub (Apr 21, 2022): Proxy is not support for notifications.
Author
Owner

@a2940uw commented on GitHub (Apr 21, 2022):

Proxy is not support for notifications.

Hi Louis, Thank you for your reply, it is possible to apply the proxy setting in the notification ?

@a2940uw commented on GitHub (Apr 21, 2022): > Proxy is not support for notifications. Hi Louis, Thank you for your reply, it is possible to apply the proxy setting in the notification ?
Author
Owner

@thmarti commented on GitHub (May 3, 2022):

See #616

@thmarti commented on GitHub (May 3, 2022): See #616
Author
Owner

@github-actions[bot] commented on GitHub (Sep 21, 2022):

We are clearing up our old issues and your ticket has been open for 3 months with no activity. Remove stale label or comment or this will be closed in 7 days.

@github-actions[bot] commented on GitHub (Sep 21, 2022): We are clearing up our old issues and your ticket has been open for 3 months with no activity. Remove stale label or comment or this will be closed in 7 days.
Author
Owner

@github-actions[bot] commented on GitHub (Sep 24, 2022):

This issue was closed because it has been stalled for 2 days with no activity.

@github-actions[bot] commented on GitHub (Sep 24, 2022): This issue was closed because it has been stalled for 2 days with no activity.
Author
Owner

@screencomuser commented on GitHub (Mar 23, 2023):

I am seeing this error in 1.21.0 - both notifications and test.

Tried to recreate using a standalone script and the only way to get this exception is to have some error in the try/catch that doesn't set a response property

const axios = require("axios");

async function send(telegramBotToken) {
  let okMsg = "Sent Successfully.";

  try {
    let params = {
      chat_id: '12345678',
      text: 'Test message',
      disable_notification: false,
      protect_content: false,
    };

    await axios.get(`https://api.telegram.org/bot${telegramBotToken}/sendMessage`, {
      params: params,
    });
    return okMsg;

  } catch (error) {
    let msg = (error.response.data.description) ? error.response.data.description : "Error without description";
    throw new Error(msg);
  }
}

(async () => {
  send('12345678900:token-characters');
})();

When I remove the line const axios = require("axios"); I get the following error, which leads me to believe a non-axios error is being thrown

TypeError: Cannot read properties of undefined (reading 'data')
    at send (/home/workspace/temp/telegram/test.js:20:31)
    at /home/workspace/temp/telegram/test.js:26:3
    at Object.<anonymous> (/home/workspace/temp/telegram/test.js:27:3)
    at Module._compile (node:internal/modules/cjs/loader:1254:14)
    at Module._extensions..js (node:internal/modules/cjs/loader:1308:10)
    at Module.load (node:internal/modules/cjs/loader:1117:32)
    at Module._load (node:internal/modules/cjs/loader:958:12)
    at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:81:12)
    at node:internal/main/run_main_module:23:47

A fix could be to check if the exception has a response property

@screencomuser commented on GitHub (Mar 23, 2023): I am seeing this error in 1.21.0 - both notifications and test. Tried to recreate using a standalone script and the only way to get this exception is to have some error in the try/catch that doesn't set a response property ```javascript const axios = require("axios"); async function send(telegramBotToken) { let okMsg = "Sent Successfully."; try { let params = { chat_id: '12345678', text: 'Test message', disable_notification: false, protect_content: false, }; await axios.get(`https://api.telegram.org/bot${telegramBotToken}/sendMessage`, { params: params, }); return okMsg; } catch (error) { let msg = (error.response.data.description) ? error.response.data.description : "Error without description"; throw new Error(msg); } } (async () => { send('12345678900:token-characters'); })(); ``` When I remove the line `const axios = require("axios");` I get the following error, which leads me to believe a non-axios error is being thrown ```text TypeError: Cannot read properties of undefined (reading 'data') at send (/home/workspace/temp/telegram/test.js:20:31) at /home/workspace/temp/telegram/test.js:26:3 at Object.<anonymous> (/home/workspace/temp/telegram/test.js:27:3) at Module._compile (node:internal/modules/cjs/loader:1254:14) at Module._extensions..js (node:internal/modules/cjs/loader:1308:10) at Module.load (node:internal/modules/cjs/loader:1117:32) at Module._load (node:internal/modules/cjs/loader:958:12) at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:81:12) at node:internal/main/run_main_module:23:47 ``` A fix could be to check if the exception has a response property
Author
Owner

@louislam commented on GitHub (Mar 23, 2023):

I am seeing this error in 1.21.0 - both notifications and test.

Tried to recreate using a standalone script and the only way to get this exception is to have some error in the try/catch that doesn't set a response property

const axios = require("axios");

async function send(telegramBotToken) {
  let okMsg = "Sent Successfully.";

  try {
    let params = {
      chat_id: '12345678',
      text: 'Test message',
      disable_notification: false,
      protect_content: false,
    };

    await axios.get(`https://api.telegram.org/bot${telegramBotToken}/sendMessage`, {
      params: params,
    });
    return okMsg;

  } catch (error) {
    let msg = (error.response.data.description) ? error.response.data.description : "Error without description";
    throw new Error(msg);
  }
}

(async () => {
  send('12345678900:token-characters');
})();

When I remove the line const axios = require("axios"); I get the following error, which leads me to believe a non-axios error is being thrown

TypeError: Cannot read properties of undefined (reading 'data')
    at send (/home/workspace/temp/telegram/test.js:20:31)
    at /home/workspace/temp/telegram/test.js:26:3
    at Object.<anonymous> (/home/workspace/temp/telegram/test.js:27:3)
    at Module._compile (node:internal/modules/cjs/loader:1254:14)
    at Module._extensions..js (node:internal/modules/cjs/loader:1308:10)
    at Module.load (node:internal/modules/cjs/loader:1117:32)
    at Module._load (node:internal/modules/cjs/loader:958:12)
    at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:81:12)
    at node:internal/main/run_main_module:23:47

A fix could be to check if the exception has a response property

Good point, i think you are right.

error.response could be undefined in case of non-http errors. Feel free to create a pull request to fix this issue if you want to be a contributor.

@louislam commented on GitHub (Mar 23, 2023): > I am seeing this error in 1.21.0 - both notifications and test. > > Tried to recreate using a standalone script and the only way to get this exception is to have some error in the try/catch that doesn't set a response property > > ```js > const axios = require("axios"); > > async function send(telegramBotToken) { > let okMsg = "Sent Successfully."; > > try { > let params = { > chat_id: '12345678', > text: 'Test message', > disable_notification: false, > protect_content: false, > }; > > await axios.get(`https://api.telegram.org/bot${telegramBotToken}/sendMessage`, { > params: params, > }); > return okMsg; > > } catch (error) { > let msg = (error.response.data.description) ? error.response.data.description : "Error without description"; > throw new Error(msg); > } > } > > (async () => { > send('12345678900:token-characters'); > })(); > ``` > > When I remove the line `const axios = require("axios");` I get the following error, which leads me to believe a non-axios error is being thrown > > ``` > TypeError: Cannot read properties of undefined (reading 'data') > at send (/home/workspace/temp/telegram/test.js:20:31) > at /home/workspace/temp/telegram/test.js:26:3 > at Object.<anonymous> (/home/workspace/temp/telegram/test.js:27:3) > at Module._compile (node:internal/modules/cjs/loader:1254:14) > at Module._extensions..js (node:internal/modules/cjs/loader:1308:10) > at Module.load (node:internal/modules/cjs/loader:1117:32) > at Module._load (node:internal/modules/cjs/loader:958:12) > at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:81:12) > at node:internal/main/run_main_module:23:47 > ``` > > A fix could be to check if the exception has a response property Good point, i think you are right. `error.response` could be undefined in case of non-http errors. Feel free to create a pull request to fix this issue if you want to be a contributor.
Author
Owner

@screencomuser commented on GitHub (Mar 23, 2023):

I traced down the error to a DNS configuration error in my pod (on k3s)

It appears that the default resolv.conf had an ndots:5 setting, which of course is too much for api.telegram.org

Changing it to ndots:1 fixed the error.

I will create a pull request which handles the error a little more graceful in the event of an Axios error that doesn't have a response.property

@screencomuser commented on GitHub (Mar 23, 2023): I traced down the error to a DNS configuration error in my pod (on k3s) It appears that the default resolv.conf had an ndots:5 setting, which of course is too much for api.telegram.org Changing it to ndots:1 fixed the error. I will create a pull request which handles the error a little more graceful in the event of an Axios error that doesn't have a response.property
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/uptime-kuma#1007
No description provided.