Skip to content

Commit

Permalink
fix(slack): did not check JSON marshaling errors
Browse files Browse the repository at this point in the history
  • Loading branch information
favonia committed Nov 5, 2023
1 parent 26fdc62 commit 481b5ab
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions pkg/services/slack/slack.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,9 +84,10 @@ func (service *Service) sendAPI(config *Config, payload interface{}) error {

func (service *Service) sendWebhook(config *Config, payload interface{}) error {
payloadBytes, err := json.Marshal(payload)
var res *http.Response
res, err = http.Post(config.Token.WebhookURL(), jsonclient.ContentType, bytes.NewBuffer(payloadBytes))

if err != nil {
return fmt.Errorf("failed to marshal payload: %w", err)
}

Check warning on line 89 in pkg/services/slack/slack.go

View check run for this annotation

Codecov / codecov/patch

pkg/services/slack/slack.go#L88-L89

Added lines #L88 - L89 were not covered by tests
res, err := http.Post(config.Token.WebhookURL(), jsonclient.ContentType, bytes.NewBuffer(payloadBytes))
if err != nil {
return fmt.Errorf("failed to invoke webhook: %w", err)
}
Expand Down

0 comments on commit 481b5ab

Please sign in to comment.