fix: unquote environment variable passed to hook commands#410
fix: unquote environment variable passed to hook commands#410
Conversation
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #410 +/- ##
==========================================
- Coverage 68.62% 68.62% -0.01%
==========================================
Files 218 218
Lines 18162 18164 +2
==========================================
+ Hits 12464 12465 +1
- Misses 4538 4539 +1
Partials 1160 1160 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
zimeg
left a comment
There was a problem hiding this comment.
💌 Notes on code for the amazing reviewers! I am also planning to follow up with testing notes before asking for particular review 🧪 ✨
| var cmdEnvVars = os.Environ() | ||
| cmdEnvVars = append(cmdEnvVars, goutils.MapToStringSlice(opts.Env, "")...) | ||
| for name, value := range opts.Env { | ||
| cmdEnvVars = append(cmdEnvVars, name+"="+value) |
There was a problem hiding this comment.
🔭 note: These values are set for both the default and message-boundaries protocols:
slack-cli/internal/hooks/shell.go
Lines 56 to 59 in 8056444
| // To avoid removing any environment variables that are set in the current environment, we first set the cmd.Env to the current environment. | ||
| // before adding any new environment variables. | ||
| var cmdEnvVars = os.Environ() | ||
| cmdEnvVars = append(cmdEnvVars, goutils.MapToStringSlice(sdkManagedConnectionStartHookOpts.Env, "")...) |
There was a problem hiding this comment.
🏁 note: I understand the MapToStringSlice utilities to be useful in escaping command line arguments but we might not need this with the direct environment variable value setting in commands.
🏆 ramble: This implementation in localserver is the other find of a direct call to the hooks command executor so shares the change!
|
🔬 More findings on the scope of this bug and confidence in a safe changes! 🐛 Hooks impacted This PR changes how environment variables are set for both hook scripts and the The slack-cli/internal/pkg/platform/localserver.go Lines 279 to 311 in e1bebf8 $ slack create asdf -t slack-samples/bolt-js-starter-template
$ cd asdf
$ vim app.jsconst app = new App({
...
socketMode: true,
appToken: process.env.SLACK_CLI_XAPP, // Change this from SLACK_APP_TOKEN to SLACK_CLI_XAPP
});$ slack run
...
[ERROR] bolt-app Failed to start the app Error: An API error occurred: invalid_authWith the changes of this branch, the token is passed as the expected string! The common slack-cli/internal/pkg/apps/install.go Lines 844 to 873 in e1bebf8 The slack-cli/internal/pkg/platform/run.go Lines 103 to 130 in e1bebf8 slack-cli/internal/pkg/platform/localserver.go Lines 197 to 221 in e1bebf8 Overall I'm feeling alright that this change is a fix for unnoticed bugs in our hook implementation and we'll match specs closer more 🤓 📣 Please do callout misunderstandings in these scopes! I'm hoping these findings can be useful in testing too! |
Changelog
Summary
This PR fixes an issue where environment variables were set with double quotes surrounding values:
slack-cli/internal/goutils/map.go
Lines 23 to 39 in 8056444
📚 Reference: https://pkg.go.dev/os/exec#Cmd
Requirements