hubot-grafana
hubot-grafana copied to clipboard
Slack upload fails with `TypeError: this.robot.adapter.client.web.files.uploadV2 is not a function`
Describe the bug
When using with the listed versions, the script package is unable to Slack's file upload API.
To Reproduce
Steps to reproduce the behavior:
- Data source: Grafana Cloud Free
- Command entered:
hubot graf db linux-node-fleet-overview - See error
Overview - [Slack files.upload Error: can't upload file] - https://orgname.grafana.net/d/nodes/?panelId=1&fullscreen&from=now-6h&to=now
[9:52](https://orgname.slack.com/archives/D03536NFP/p1721573563858969)
Uptime - [Slack files.upload Error: can't upload file] - https://orgname.grafana.net/d/nodes/?panelId=2&fullscreen&from=now-6h&to=now
[9:52](https://orgname.slack.com/archives/D03536NFP/p1721573570361849)
Hostname - [Slack files.upload Error: can't upload file] - https://orgname.grafana.net/d/nodes/?panelId=3&fullscreen&from=now-6h&to=now
[9:53](https://orgname.slack.com/archives/D03536NFP/p1721573586190369)
Kernel version - [Slack files.upload Error: can't upload file] - https://orgname.grafana.net/d/nodes/?panelId=4&fullscreen&from=now-6h&to=now
[9:53](https://orgname.slack.com/archives/D03536NFP/p1721573592491159)
OS - [Slack files.upload Error: can't upload file] - https://orgname.grafana.net/d/nodes/?panelId=5&fullscreen&from=now-6h&to=now
Expected behavior
The TypeError indicates we may need to do some extra checking of the loaded-in Slack adapter, and possibly switch behavior if the uploadV2 method is not present.
Logs
{"level":20,"time":1721573681177,"pid":20,"hostname":"4a005511c918","name":"hubot","msg":"SlackClient#send() room: D03536NFP, message: Disk - [Slack files.upload Error: can't upload file] - https://orgname.grafana.net/d/nodes/?panelId=17&fullscreen&from=now-6h&to=now"}
{"level":20,"time":1721573687485,"pid":20,"hostname":"4a005511c918","name":"hubot","msg":"Uploading file: 6462 bytes, content-type[image/png]"}
{"level":50,"time":1721573687485,"pid":20,"hostname":"4a005511c918","name":"hubot","err":{"type":"TypeError","message":"this.robot.adapter.client.web.files.uploadV2 is not a function","stack":"TypeError: this.robot.adapter.client.web.files.uploadV2 is not a function\n at SlackUploader.upload (/opt/hubot/node_modules/hubot-grafana/src/adapters/implementations/SlackUploader.js:47:49)\n at Bot.sendDashboardChart (/opt/hubot/node_modules/hubot-grafana/src/Bot.js:118:27)\n at runMicrotasks (<anonymous>:null:null)\n at processTicksAndRejections (node:internal/process/task_queues:96:5)\n at Bot.sendDashboardChartFromString (/opt/hubot/node_modules/hubot-grafana/src/Bot.js:88:7)\n"},"msg":"SlackUploader.upload.uploadFile"}
{"level":20,"time":1721573687487,"pid":20,"hostname":"4a005511c918","name":"hubot","msg":"SlackClient#send() room: D03536NFP, message: Disk reads/writes - [Slack files.upload Error: can't upload file] - https://orgname.grafana.net/d/nodes/?panelId=18&fullscreen&from=now-6h&to=now"}
{"level":20,"time":1721573693787,"pid":20,"hostname":"4a005511c918","name":"hubot","msg":"Uploading file: 15423 bytes, content-type[image/png]"}
{"level":50,"time":1721573693787,"pid":20,"hostname":"4a005511c918","name":"hubot","err":{"type":"TypeError","message":"this.robot.adapter.client.web.files.uploadV2 is not a function","stack":"TypeError: this.robot.adapter.client.web.files.uploadV2 is not a function\n at SlackUploader.upload (/opt/hubot/node_modules/hubot-grafana/src/adapters/implementations/SlackUploader.js:47:49)\n at Bot.sendDashboardChart (/opt/hubot/node_modules/hubot-grafana/src/Bot.js:118:27)\n at runMicrotasks (<anonymous>:null:null)\n at processTicksAndRejections (node:internal/process/task_queues:96:5)\n at Bot.sendDashboardChartFromString (/opt/hubot/node_modules/hubot-grafana/src/Bot.js:88:7)\n"},"msg":"SlackUploader.upload.uploadFile"}
Software:
- Grafana: Grafana Cloud
- Hubot:
4.1.0 - Adapter:
[email protected]/@slack/[email protected] - Node:
v16.20.2 - NPM:
8.19.4
Additional context
Add any other context about the problem here.
It looks like it's getting the image itself without issue, but running into trouble with a mismatch between the (now legacy) Slack adapter for Hubot and the @slack/web-api version. Not entirely sure what it should try to fall back to.
Switching back to the old method might work, but I would advise to upgrade anyway, as files.upload is deprecated and will stop working on March 11, 2025. New app are not able to use it since May 8, 2024.
Source: https://api.slack.com/methods/files.upload
same issue I facing with, is it possible to fix the issue before files.upload retired, please
I'm a bit fuzzy on it, but I think anyone using the current hubot-slack adapter is going to lose access next month, irrespective of this package. 😞 Organizations will need to swap over to @hubot-friends/hubot-slack, which has a different set up process.
Finally got it back up and running. One thing to note is that files:write isn't mentioned in the default manifest for @hubot-friends/hubot-slack, so that may be an extra step. Added it as a note in the wiki.