Skip to content

fix: require a custom 'api' url to send to instead of absolute urls as a 'method' #420

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 9 commits into
base: main
Choose a base branch
from

Conversation

zimeg
Copy link
Member

@zimeg zimeg commented Mar 27, 2025

Summary

This PR requires using a custom api URL in step inputs to send to URLs that are not "https://slack.com/api/".

Fixes unexpected behaviors noted in slackapi/node-slack-sdk#2176 for steps using a variable method for cases of composite action workflows or of variable inputs from outputs of a different step.

No change to functionalities when using as a standalone step!

Preview

The format shown in the README.md is now required to send to a custom api URL:

  - name: Post text to a Slack channel
    uses: slackapi/slack-github-action
    with:
-     method: http://localhost:8080/chat.postMessage
+     api: http://localhost:8080/
+     method: chat.postMessage
      token: ${{ secrets.SLACK_BOT_TOKEN }}
      payload: |
        channel: ${{ secrets.SLACK_CHANNEL_ID }}
        text: "howdy <@channel>!"

Requirements

@zimeg zimeg added bug Something isn't working semver:patch labels Mar 27, 2025
@zimeg zimeg added this to the 2.1 milestone Mar 27, 2025
@zimeg zimeg self-assigned this Mar 27, 2025
Copy link

codecov bot commented Mar 27, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 99.85%. Comparing base (e7edf37) to head (ced6b72).
Report is 7 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #420   +/-   ##
=======================================
  Coverage   99.85%   99.85%           
=======================================
  Files           7        7           
  Lines         702      703    +1     
=======================================
+ Hits          701      702    +1     
  Misses          1        1           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Copy link
Contributor

@WilliamBergamin WilliamBergamin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems good to me 💯

But any chance we could add a unit test that ensures the override configuration sends a request to the correct uri?
I looked through the test but did not find such a test, but maybe I missed it

Copy link
Member

@mwbrooks mwbrooks left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good call @WilliamBergamin - I agree, a test would be great. Otherwise, looks good! 👌🏻

@zimeg
Copy link
Member Author

zimeg commented May 1, 2025

@WilliamBergamin @mwbrooks Thank y'all both for the reviews 🙏

These tests were stumping me for a bit longer than I'd like to admit but related work in an adjacent repo brought some great inspiration 😉

But any chance we could add a unit test that ensures the override configuration sends a request to the correct uri?

This doesn't seem simple without catching actual HTTP requests, but we now test that the expected arguments are used in both the WebClient constructor and .apiCall method.

For now I'm hoping this is alright with the upstream tests we also have:

https://github.com/slackapi/node-slack-sdk/blob/29c1e1aff222a8c40513c55e874c5a9149131f40/packages/web-api/src/WebClient.spec.ts#L534-L546

Copy link
Contributor

@WilliamBergamin WilliamBergamin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice work 💯

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working semver:patch
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants