Skip to content

Commit

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

* fix(bitbucketcloud): Ensure status key has at most 40 characters

* Use fmt.Sprintf()
  • Loading branch information
maxbrunet authored and krrrr38 committed Dec 16, 2022
1 parent 14bcb03 commit a84104a
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 a84104a

Please sign in to comment.