slackapi / deno-slack-sdk

SDK for building Run on Slack apps using Deno
https://api.slack.com/automation
MIT License
158 stars 27 forks source link

[BUG] client.chat.update method not working #212

Closed tsarni closed 11 months ago

tsarni commented 1 year ago

The deno-slack versions

"deno-slack-sdk/": "https://deno.land/x/deno_slack_sdk@2.2.0/", "deno-slack-api/": "https://deno.land/x/deno_slack_api@2.1.1/"

Deno runtime version

deno 1.36.1 (release, aarch64-apple-darwin) v8 11.6.189.12 typescript 5.1.6

OS info

ProductName: macOS ProductVersion: 13.4 BuildVersion: 22F66

Describe the bug

client.chat.update method returns following error:

error: "invalid_arguments",
response_metadata: { messages: [ "[ERROR] missing required field: channel" ] }

If I have channel defined as channel name(#channel-name) the error is error: "channel_not_found", but if I use the channel id as value instead, it gives the above error.

If I do the same request via Slack API as HTTP call with same details (that is exactly same payload with channel id) it works.

Steps to reproduce

const updated = await client.chat.update({ channel: "Channel id string", ts: "id of the message", blocks: "blocks, });

Expected result

Successfully update the channel post with new content

Actual result

filmaj commented 1 year ago

Hey @tsarni , I am unable to reproduce this issue. We have a request-time-off sample app that I tested this with. This app's custom function uses chat.update like so:

    const msgUpdate = await client.chat.update({
      channel: body.container.channel_id,
      ts: body.container.message_ts,
      blocks: timeOffRequestHeaderBlocks(body.function_data.inputs).concat([
        {
          type: "context",
          elements: [
            {
              type: "mrkdwn",
              text: `${
                approved ? " :white_check_mark: Approved" : ":x: Denied"
              }`,
            },
          ],
        },
      ]),
    });

And the above works fine. Are you able to provide an app where I can reproduce this?

tsarni commented 11 months ago

I think I was able to figure out this. It turned out that I was using a wrong env variable and instead of channel id it was indeed still putting a channel name. Thus it did not work. I was able to get it working with the sample you provided.