Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion internal/hooks/hook_executor_default.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,12 @@ func (e *HookExecutorDefaultProtocol) Execute(ctx context.Context, opts HookExec
response := strings.TrimSpace(buffout.String())
if err != nil {
return "", slackerror.New(slackerror.ErrSDKHookInvocationFailed).
WithMessage("Command for '%s' returned an error: %s\n%s", opts.Hook.Name, err, strings.TrimSpace(bufferr.String()))
WithMessage("Error running '%s' command: %s", opts.Hook.Name, err).
WithDetails(slackerror.ErrorDetails{
{
Message: strings.TrimSpace(bufferr.String()),
},
})
}

// Special handling for the baseline protocol for the `start` hook
Expand Down
7 changes: 6 additions & 1 deletion internal/hooks/hook_executor_default_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,12 @@ func Test_Hook_Execute_Default_Protocol(t *testing.T) {
},
},
expectedError: slackerror.New(slackerror.ErrSDKHookInvocationFailed).
WithMessage("Command for 'sadpath' returned an error: explosion\nthere was a problem compiling your app"),
WithMessage("Error running 'sadpath' command: explosion").
WithDetails(slackerror.ErrorDetails{
slackerror.ErrorDetail{
Message: "there was a problem compiling your app",
},
}),
expectedResponse: "",
},
"successful deploy command": {
Expand Down
7 changes: 6 additions & 1 deletion internal/hooks/hook_executor_v2.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,12 @@ func (e *HookExecutorMessageBoundaryProtocol) Execute(ctx context.Context, opts
cmd := opts.Exec.Command(cmdEnvVars, &stdout, stderr, opts.Stdin, cmdArgs[0], cmdArgVars...)
if err = cmd.Run(); err != nil {
return "", slackerror.New(slackerror.ErrSDKHookInvocationFailed).
WithMessage("Error running '%s' command: %s", opts.Hook.Name, err)
WithMessage("Error running '%s' command: %s", opts.Hook.Name, err).
WithDetails(slackerror.ErrorDetails{
{
Message: strings.TrimSpace(bufferr.String()),
},
})
}
return buffout.String(), nil
}
Expand Down
12 changes: 10 additions & 2 deletions internal/hooks/hook_executor_v2_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -113,13 +113,21 @@ func Test_Hook_Execute_V2_Protocol(t *testing.T) {
Hook: HookScript{Command: "boom", Name: "sadpath"},
Exec: &MockExec{
mockCommand: &MockCommand{
Err: errors.New("explosion"),
Err: errors.New("explosion"),
MockStderr: []byte("fireworks for the skies above"),
},
},
},
check: func(t *testing.T, response string, err error, mockExec ExecInterface) {
require.Equal(t, slackerror.New(slackerror.ErrSDKHookInvocationFailed).
WithMessage("Error running 'sadpath' command: explosion"), err)
WithMessage("Error running 'sadpath' command: explosion").
WithDetails(slackerror.ErrorDetails{
slackerror.ErrorDetail{
Message: "fireworks for the skies above",
},
}),
err,
)
},
},
"fail to parse payload due to improper boundary strings": {
Expand Down
2 changes: 1 addition & 1 deletion internal/shared/clients_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,7 @@ func Test_ClientFactory_InitSDKConfigFromJSON_brokenGetHooks(t *testing.T) {
err := clients.InitSDKConfigFromJSON(ctx, []byte(getHooksJSON))
require.Error(t, err)
assert.Equal(t, slackerror.New(slackerror.ErrSDKHookInvocationFailed).Code, slackerror.ToSlackError(err).Code)
assert.Contains(t, slackerror.ToSlackError(err).Message, "Command for 'GetHooks' returned an error")
assert.Contains(t, slackerror.ToSlackError(err).Message, "Error running 'GetHooks' command")
}

func Test_ClientFactory_InitSDKConfigFromJSON_brokenJSONFile(t *testing.T) {
Expand Down
Loading