slackapi / slack-github-action

Send data into Slack using this GitHub Action!
MIT License
938 stars 148 forks source link

Update of existing slack post does not work with channel name, only channel id #136

Closed brownjeff closed 2 years ago

brownjeff commented 2 years ago

Description

When using update-ts: to update a previous action's slack post, the error Error: An API error occurred: channel_not_found is thrown.

The update works fine when using the channel ID, but does not work when using channel name.

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

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


Bug Report

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

Reproducible in:

package version:

node version:

OS version(s):

Steps to reproduce:

  1. Create subsequent actions like:
      - name: Post to a Slack channel
        id: slack
        uses: slackapi/slack-github-action@v1.22.0
        with:
          channel-id: '#mychannel'
          payload: |
            {
              "text": "first message"
            }
      - name: Update Existing Message in Slack
        id: slack_update
        uses: slackapi/slack-github-action@v1.22.0
        with:
          channel-id: '#mychannel'
          update-ts: ${{ steps.slack.outputs.ts }}
          payload: |
            {
              "text": "UPDATED MESSAGE"
            }
  2. Note: token set in env at global level
  3. Execute the workflow
  4. Notice first message is posted to slack
  5. Notice the slack post if never updated.
  6. Notice in github action page an error has occur with message: Error: An API error occurred: channel_not_found

Expected result:

Existing post is updated with the subsequent action.

Actual result:

Notice in github action page an error has occur with message: Error: An API error occurred: channel_not_found

Attachments:

WilliamBergamin commented 2 years ago

Hi @brownjeff thanks for writing in!

I suspect this may be related to the way the channel information is provided. When posting a message the postMessage method accepts a channel encoded ID, or a name as input. And based on the documentation, in the case of updateMessage only the channel encoded ID can be provided.

let me know if using the channel name instead of the channel_id is the source of this issue

brownjeff commented 2 years ago

Thanks for the reply @WilliamBergamin

You are correct. Using the channel name instead of the channel_id is the source of this issue.

Thanks for the links to the methods' docs.

I suppose this should not be a bug report here, but a feature request to the Slack API for adding channel-name as a valid alternative to channel-id in the updateMessage call.

Thanks again.