hubot-grafana icon indicating copy to clipboard operation
hubot-grafana copied to clipboard

Slack upload fails with `TypeError: this.robot.adapter.client.web.files.uploadV2 is not a function`

Open stephenyeargin opened this issue 1 year ago • 4 comments
trafficstars

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:

  1. Data source: Grafana Cloud Free
  2. Command entered: hubot graf db linux-node-fleet-overview
  3. 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:

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.

stephenyeargin avatar Jul 21 '24 15:07 stephenyeargin

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.

image

Source: https://api.slack.com/methods/files.upload

KeesCBakker avatar Dec 11 '24 09:12 KeesCBakker

same issue I facing with, is it possible to fix the issue before files.upload retired, please

hung86223 avatar Feb 26 '25 09:02 hung86223

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.

stephenyeargin avatar Feb 26 '25 19:02 stephenyeargin

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.

stephenyeargin avatar Mar 01 '25 04:03 stephenyeargin