From a84104a6cc0ad905fe6c9e821efd2a6b9562df7b Mon Sep 17 00:00:00 2001 From: Maxime Brunet Date: Mon, 7 Mar 2022 08:19:55 -0800 Subject: [PATCH] fix(bitbucketcloud): Ensure status key has at most 40 characters (#2037) * fix(bitbucketcloud): Ensure status key has at most 40 characters * Use fmt.Sprintf() --- server/events/vcs/bitbucketcloud/client.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/server/events/vcs/bitbucketcloud/client.go b/server/events/vcs/bitbucketcloud/client.go index b926c8cf4a..598bce5df6 100644 --- a/server/events/vcs/bitbucketcloud/client.go +++ b/server/events/vcs/bitbucketcloud/client.go @@ -6,6 +6,7 @@ import ( "fmt" "io" "net/http" + "unicode/utf8" "github.com/pkg/errors" "github.com/runatlantis/atlantis/server/events/models" @@ -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,