Skip to content

Bug: No longer able to set webhook type via environment variable #372

Closed as not planned

Description

@jacob-white-simplisafe

Description

Describe your issue here.
After upgrading this action to version 2.0.0 you are no longer able to set the webhook type with an environment variable. I did not see a breaking change not

What type of issue is this?

  • bug
  • enhancement (feature request)
  • question
  • documentation related
  • example code related
  • testing related
  • discussion

Requirements

  • I've read and understood the Contributing guidelines and have done my best effort to follow them.
  • I've read and agree to the Code of Conduct.
  • 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.

Reproducible in:

package version:
2.0.0
node version:
20
OS version(s):
Ubuntu

Steps to reproduce:

  1. Set up the action with the following code block
      - name: Notify failure
        env:
          SLACK_CHANNEL_ID: "<slack channel>"
          CURRENT_DATE: ${{ steps.getCurrentDate.outputs.CURRENT_DATE }}
          SLACK_WEBHOOK_TYPE: INCOMING_WEBHOOK. 
        uses: slackapi/slack-github-action@v2.0.0
        with:
          payload-file-path: ${{ env.SLACK_FAILURE_PAYLOAD_FILE_PATH }}
  1. Run it

Expected result:

A message is sent using as incoming webhook

Actual result:

Get an error of SlackError: Missing input! The webhook type must be 'incoming-webhook' or 'webhook-trigger'.

Attachments:

This could be changed in https://github.com/slackapi/slack-github-action/blob/main/src/config.js#L111 by changing it to webhookType: core.getInput("webhook-type") || process.env.SLACK_WEBHOOK_TYPE, which matches the environment variable that previously worked.

if (process.env.SLACK_WEBHOOK_TYPE) {
// The default type is for Workflow Builder triggers. If you want to use this action for Incoming Webhooks, use
// the corresponding type instead.
webhookType = process.env.SLACK_WEBHOOK_TYPE.toUpperCase();
}

Activity

  1. added this to the 2.x milestone on Dec 4, 2024
  2. zimeg commented on Dec 4, 2024

    @zimeg
    Member

    Hey @jacob-white-simplisafe 👋 Thanks for writing in about this!

    You're totally right to call this out as a breaking change in v2.0.0 - the webhook-type input is a required input when sending with webhook. A few lines on this were included in the release notes under breaking changes 📚

    The recommended approach is to now set this value with the step inputs:

    - name: Notify failure
      uses: slackapi/slack-github-action@v2.0.0
      with:
        payload-file-path: ${{ env.SLACK_FAILURE_PAYLOAD_FILE_PATH }}
        payload-templated: true
        webhook: ${{ secrets.SLACK_WEBHOOK_URL }}
        webhook-type: incoming-webhook
      env:
        CURRENT_DATE: ${{ steps.getCurrentDate.outputs.CURRENT_DATE }}
        SLACK_CHANNEL_ID: "C0123456789"

    I understand that using env to set these values was a convenience from v1, and using this environment variable was added after the initial release, but discussions from #221 have pointed us towards with to add clarity to the inputs.

    Hoping this helps a bit, but I'm curious to know if the updated approach is alright or if env can be useful in more cases here. Open to discussing changes if so, so please let me know! 🙏

  3. jacob-white-simplisafe commented on Dec 4, 2024

    @jacob-white-simplisafe
    Author

    Thanks for the clarification!
    I read the section of the release notes:

    This Action now requires setting the webhook-type as a step input value.
    Prior to updating: The webhook type could be omitted to send to Workflow Builder.
    Recommended change: Set the webhook-type value to incoming-webhook, as shown in the example below:
    

    As it was now required to have the webhook-type set but didn't have to be only supplied with the with statement.

    For us, env is helpful because we have multiple jobs/steps where we are sending messages, so it was nice to be able to set the webhook type for all the steps. A more realistic example of how we use it is

    on: push
    
    env:
      SLACK_WEBHOOK_TYPE: INCOMING_WEBHOOK
      SLACK_FAILURE_PAYLOAD_FILE_PATH: <path>
    
    jobs:
       job1:
         steps:
           ### Do stuff
           uses: slackapi/slack-github-action@v2.0.0
    
       job2:
         steps:
           ### Do stuff
           uses: slackapi/slack-github-action@v2.0.0
       

    Happy to close this out, if the decision was to require the use of with.

  4. zimeg commented on Dec 5, 2024

    @zimeg
    Member

    @jacob-white-simplisafe That example makes a ton of sense! 🙌

    Despite being a bit more verbose, I do still think with makes each step more clear when making changes or adding other techniques. I'm hoping that's alright with your implementations!

    I'd also be super interested in learning about workflows where the webhook-type might change within a certain step, but that might not be so common...

  5. zimeg commented on Dec 5, 2024

    @zimeg
    Member

    And thinking about the current SLACK_TOKEN and SLACK_WEBHOOK_URL variables - we might have a not so ideal error happening with this:

    case !!this.inputs.token && !!this.inputs.webhook:

    I'm thinking this token needs to be replaced with method (these are a required pairing) since token and webhook might be set from environment variables shared throughout a workflow!

    Confirming this errors then I'll open a separate issue, but this pokes at a fear I have using environment variables 👻

  6. jacob-white-simplisafe commented on Dec 6, 2024

    @jacob-white-simplisafe
    Author

    Despite being a bit more verbose, I do still think with makes each step more clear when making changes or adding other techniques. I'm hoping that's alright with your implementations!

    This sounds good to me. I agree it does make sense, and we can just use an environment variable to reduce repeating.

  7. takirala commented on Jun 13, 2025

    @takirala

    @jacob-white-simplisafe Does this also mean that https://github.com/slackapi/slack-github-action/blob/v2.1.0/action.yml#L40 webhook is no longer an optional field ? I got this error:

    Run slackapi/slack-github-action@v2.1.0
    Error: Missing input! The webhook type must be 'incoming-webhook' or 'webhook-trigger'.
    SlackError: Missing input! The webhook type must be 'incoming-webhook' or 'webhook-trigger'.
        at Config.validate (file:///runner/_work/_actions/slackapi/slack-github-action/v2.1.0/src/config.js:177:1)
    
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions