slack-github-action icon indicating copy to clipboard operation
slack-github-action copied to clipboard

sometimes payloads are sent to the wrong channel

Open ipavlov314 opened this issue 1 year ago • 4 comments

Description

I see that sometimes payloads are sent to the wrong channel.

I have channels for pr-notifications and nightly-notifications, with two separate workflows for PRs and Nightly builds. Somehow, PR payloads with results are sent to nightly-notifications. Some days it happens more, some days less.

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

  • [ x] bug
  • [ ] enhancement (feature request)
  • [ ] question
  • [ ] documentation related
  • [ ] example code 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

Reproducible in:

package version: slackapi/slack-github-action@70cd7be8e40a46e8b0eced40b0de447bdb42f68e # v1.2.6

node version:

OS version(s): Mac 14.2.1 (23C71)

Steps to reproduce:

  1. Not clear how to reproduce

Expected result:

Payload should be send only to provided channels

Actual result:

I see that sometimes payloads are sent to the wrong channel.

Attachments:

Set up I have

// action file with inputs 
slack_auth:
    required: false
    default: ""
  slack_channel:
    required: false
    default: "Please provide a Slack channel ID."
    
    - name: Send UITests results to Slack
      id: slack
      uses: slackapi/slack-github-action@70cd7be8e40a46e8b0eced40b0de447bdb42f68e # v1.2.6
      if: success() || failure()
      with:
        payload-file-path: "myPath\payload.json"
        channel-id: ${{ inputs.slack_channel }}
      env:
        SLACK_BOT_TOKEN: ${{ inputs.slack_auth }} 
        
 // from workflow for Nightly I have 
 
 .....
       
        slack_auth: ${{ env.SLACK_ACCESS_TOKEN }}
        slack_channel: ${{ env.NIGHTLY_NOTIFICATIONS }}

// Channels ID stored in secretes as variables 

Also public channel ids are pretty different

ipavlov314 avatar Jun 03 '24 13:06 ipavlov314

Hi @ipavlov314 thanks for writing in 💯

I'm not sure how the this action may be posting to the wrong channel 🤔 From what you provided it seem like the default channel value comes from an environment variable and gets overwritten when an input value is provided, have you tried echoing the value of ${{ inputs.slack_channel }} before executing the the post message step?

This action is stateless, it does not save what channels it has posted to in the past

WilliamBergamin avatar Jun 03 '24 14:06 WilliamBergamin

Thanks for quick response. In logs for action I see it set to right channel

Run slackapi/slack-github-action@70cd7be8e40a46e8b0eced40b0de447bdb42f68e
  with:
    payload-file-path: my.json
    channel-id: XXXXX // added to mack channel id
    payload-file-path-parsed: true

However payload was send to the other one, any possible redirection regarding firewall or any other infrastructure settings you my think?

ipavlov314 avatar Jun 04 '24 13:06 ipavlov314

Have you tried printing out the channel_id output value returned from the step and ensuring it is the same one sent as an input?

I've looked at the source code there does not seem to be any logic that may change the channel-id value, I am also unable to reproduce this behavior

WilliamBergamin avatar Jun 04 '24 14:06 WilliamBergamin

I'm also a bit confused here, but can the payload-file-path content contain a top-level channel attribute different from the channel-id in the action? That might override the channel-id provided as an input parameter if so 🤔

zimeg avatar Jun 04 '24 17:06 zimeg

👋 Closing this issue as stale - the @v2 version is now released! Please feel free to comment if similar issues happen to appear though, I'm still curious about this!

zimeg avatar Nov 16 '24 03:11 zimeg