diff --git a/backend/plugins/bitbucket/api/remote_api.go b/backend/plugins/bitbucket/api/remote_api.go index d81c0d02739..2da3f7ab626 100644 --- a/backend/plugins/bitbucket/api/remote_api.go +++ b/backend/plugins/bitbucket/api/remote_api.go @@ -19,6 +19,7 @@ package api import ( "fmt" + "io" "net/http" "net/url" @@ -116,6 +117,13 @@ func listBitbucketRepos( if err != nil { return } + if res.StatusCode > 299 { + body, e := io.ReadAll(res.Body) + if e != nil { + return nil, nil, errors.BadInput.Wrap(e, "failed to read response body") + } + return nil, nil, errors.BadInput.New(string(body)) + } var resBody models.ReposResponse err = api.UnmarshalResponse(res, &resBody) if err != nil {