Node-slack-sdk: Issue with app.client.views.publish()

Created on 7 May 2020  路  4Comments  路  Source: slackapi/node-slack-sdk

Description

Describe your issue here.

I am seeing an error at app_home_opened event

Error: An API error occurred: internal_error
    at Object.platformErrorFromResult (/Users/suyashgulati/Documents/work/slack-bot/node_modules/@slack/web-api/dist/errors.js:50:33)
    at WebClient.apiCall (/Users/suyashgulati/Documents/work/slack-bot/node_modules/@slack/web-api/dist/WebClient.js:485:28)
    at processTicksAndRejections (internal/process/task_queues.js:93:5) {
  code: 'slack_webapi_platform_error',
  data: {
  ok: false,
  error: 'internal_error',
  response_metadata: { scopes: [ 'chat:write', 'commands', 'im:history' ] }
 }
}

while calling app.client.views.publish({options});

the options object is =>

{
    "user_id": "U011NU4MUJ3",
    "token": "xoxb-***",
    "view": {
        "type": "home",
        "external_id": "app_home_view",
        "blocks": [
            {
                "type": "section",
                "text": {
                    "type": "mrkdwn",
                    "text": "*Hi <@U011NU4MUJ3> !*"
                },
                "accessory": {
                    "type": "button",
                    "text": {
                        "type": "plain_text",
                        "text": "Settings :gear:",
                        "emoji": true
                    },
                    "value": "settings",
                    "action_id": "settings"
                }
            },
            {
                "type": "actions",
                "elements": [
                    {
                        "type": "button",
                        "text": {
                            "type": "plain_text",
                            "text": "Add WFH",
                            "emoji": true
                        },
                        "value": "wfh",
                        "action_id": "wfh"
                    },
                    {
                        "type": "button",
                        "text": {
                            "type": "plain_text",
                            "text": "Add DSR",
                            "emoji": true
                        },
                        "value": "dsr",
                        "action_id": "dsr"
                    }
                ]
            }
        ]
    }
}

With same inputs in tester here https://api.slack.com/methods/views.publish/test, it gives ok!

One more info, this is working fine for 1 user but not working for any other.

Object body running for that particular user:

{
    "user_id": "U011CJS2PJP",
    "token": "xoxb-****",
    "view": {
        "type": "home",
        "external_id": "app_home_view",
        "blocks": [
            {
                "type": "section",
                "text": {
                    "type": "mrkdwn",
                    "text": "*Hi <@U011CJS2PJP> !*"
                },
                "accessory": {
                    "type": "button",
                    "text": {
                        "type": "plain_text",
                        "text": "Settings :gear:",
                        "emoji": true
                    },
                    "value": "settings",
                    "action_id": "settings"
                }
            },
            {
                "type": "actions",
                "elements": [
                    {
                        "type": "button",
                        "text": {
                            "type": "plain_text",
                            "text": "Add WFH",
                            "emoji": true
                        },
                        "value": "wfh",
                        "action_id": "wfh"
                    },
                    {
                        "type": "button",
                        "text": {
                            "type": "plain_text",
                            "text": "Add DSR",
                            "emoji": true
                        },
                        "value": "dsr",
                        "action_id": "dsr"
                    }
                ]
            }
        ]
    }
}

What type of issue is this? (place an x in one of the [ ])

  • [x] bug
  • [x] enhancement (feature request)
  • [ ] question
  • [ ] documentation related
  • [ ] testing related
  • [ ] discussion

Requirements (place an x in each of the [ ])

  • [x] I've read and understood the Contributing guidelines and have done my best effort to follow them.
  • [x] I've read and agree to the Code of Conduct.
  • [x] I've searched for any related issues and avoided creating a duplicate issue.

Bug Report

Filling out the following details about bugs will help us solve your issue sooner.

Packages:

Select all that apply:

  • [ ] @slack/web-api
  • [ ] @slack/events-api
  • [ ] @slack/interactive-messages
  • [ ] @slack/rtm-api
  • [ ] @slack/webhooks
  • [ ] @slack/oauth
  • [x] I don't know

Reproducible in:

package version: 2.0.0

node version: 12.13.1

OS version(s): MacOS 10.13.6

Steps to reproduce:

  1. Call app.client.publish with above argument
  2. See the error in console
    3.

Expected result:

App home to refresh

Actual result:

Error thrown

Attachments:

Logs, screenshots, screencast, sample project, funny gif, etc.

bug web-api question server-side-issue

All 4 comments

Regarding internal_error errors, we, the SDK maintainer team, cannot help you by doing deeper investigation than the error code. I'm sorry for bothering you but could you submit a support ticket from https://my.slack.com/help/requests/new ?

@suyashgulati

I have had a same issue.
The cause is that you are using the same external_id.
external_id should be unique.

The document says: https://api.slack.com/methods/views.open

Within the view object, you can pass an external_id if you wish to use your own identifiers for views. The external_id should be a unique identifier of the view, determined by you. It must be unique for all views on a team, and it has a max length of 255 characters.

so, 1 user (first user) could see view, other user couldn't.

On the other hand, the error message from server is misleading and may need to be corrected.
https://api.slack.com/methods/views.publish
According to this document, the error message duplicate_external_id is defined.

@ShotaOd I was able to debug the issue. I guess I didn't update it because of the misleading error code.

I am guessing the new error code was added after the issue was raised. Because the doc also seems new to me.

Anyways @seratch you can close this issue if needed. 鉁岋笍
Thanks @ShotaOd for your insights! 馃憤

@ShotaOd Thanks a lot for helping @suyashgulati here! I will share the feedback about the confusing error code with the teams concerned (on the server-side) 馃檱

Was this page helpful?
0 / 5 - 0 ratings