Repository navigation
Conversation
Outside a project the --app flag was ignored and the request fell through to SLACK_BOT_TOKEN, SLACK_USER_TOKEN, or no token at all.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #845 +/- ##
==========================================
+ Coverage 80.64% 80.67% +0.02%
==========================================
Files 246 246
Lines 18837 18840 +3
==========================================
+ Hits 15192 15200 +8
+ Misses 3645 3640 -5 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
WilliamBergamin
left a comment
There was a problem hiding this comment.
💯 Thanks @mwbrooks, failing loudly here beats quietly sending the request as a different identity, and --token still wins outside a project. Nothing from me on the code. The CircleCI build job is red on this head while make build-ci passes locally and sibling PRs build green, so it could use a re-run 🙏
| } | ||
|
|
||
| func Test_resolveToken_AppFlag_NoProject(t *testing.T) { | ||
| t.Setenv("SLACK_BOT_TOKEN", "xoxb-env-bot-token") |
There was a problem hiding this comment.
💯 praise: Setting SLACK_BOT_TOKEN and asserting the prompt never runs pins the exact fallback this fixes, so the test fails on main for the right reason.
|
Thanks @WilliamBergamin for the review and the CI catch! 🙇 The |
Changelog
slack api --appnow errors when it's run outside a project, instead of ignoring the flag and sending the request with another token or none.Summary
This pull request makes
slack api --app <app>fail with a clear error for developers who run it outside a Slack project. Before, the flag was silently ignored, so the CLI usedSLACK_BOT_TOKENorSLACK_USER_TOKENif set, or sent the request with no token and printednot_authedwith exit code 0.invalid_slack_project_directory, with a suggestion to run the command in a project or pass--token.--apprequires a project.Testing
SLACK_BOT_TOKEN=xoxb-fake slack api auth.test --app A123and confirm theinvalid_slack_project_directoryerror and exit code 1.slack api auth.test --app <app-id>and confirm it still returns the bot's identity.Test_resolveToken_AppFlag_NoProjectfails onmainand passes on this branch.Notes
--appcan't get a bot token, touches the same--appbranch inresolveToken. Whichever merges second gets a small conflict.Requirements