Skip to content

Commit

Permalink
fix(bitbucketcloud): Ensure status key has at most 40 characters (#2037)
Browse files Browse the repository at this point in the history
* fix(bitbucketcloud): Ensure status key has at most 40 characters

* Use fmt.Sprintf()
  • Loading branch information
maxbrunet authored Mar 7, 2022
1 parent 4db917d commit f9a41c9
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions server/events/vcs/bitbucketcloud/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"fmt"
"io"
"net/http"
"unicode/utf8"

"github.com/pkg/errors"
"github.com/runatlantis/atlantis/server/events/models"
Expand Down Expand Up @@ -179,6 +180,11 @@ func (b *Client) UpdateStatus(repo models.Repo, pull models.PullRequest, status
url = b.AtlantisURL
}

// Ensure key has at most 40 characters
if utf8.RuneCountInString(src) > 40 {
src = fmt.Sprintf("%.37s...", src)
}

bodyBytes, err := json.Marshal(map[string]string{
"key": src,
"url": url,
Expand Down

0 comments on commit f9a41c9

Please sign in to comment.