slackapi / slack-github-action

Send data into Slack using this GitHub Action!
MIT License
905 stars 149 forks source link

sometimes payloads are sent to the wrong channel #317

Open ipavlov314 opened 3 months ago

ipavlov314 commented 3 months ago

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 [ ])

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


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

WilliamBergamin commented 3 months ago

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

ipavlov314 commented 3 months ago

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?

WilliamBergamin commented 3 months ago

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

zimeg commented 3 months ago

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 🤔