Skip to content

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

Description

@stephenyeargin

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:

  • Grafana: Grafana Cloud
  • Hubot: 4.1.0
  • Adapter: hubot-slack@4.10.0 / @slack/web-api@7.3.1
  • 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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions