Skip to content
This repository was archived by the owner on Sep 30, 2024. It is now read-only.

Commit a88bc4d

Browse files
[Backport 5.5.x] fix(source): Fix issue where worker would crash if a Bitbucket Cloud token couldn''t be refreshed (#64037)
A Bitbucket Cloud incident caused APIs to error which caused Bitbucket Cloud OAuth tokens to fail to refresh. This revealed that the Bitbucket Cloud client called `oauthutil.DoRequest` with a `nil` logger, causing a nil pointer dereference. This PR simply creates the logger before calling `DoRequest`, which is what the other clients do. ## Test plan No more cases of DoRequest with a nil logger. ## Changelog - Fixed an issue where a Bitbucket Cloud OAuth token failing to refresh would crash the `worker` service. <br> Backport bc036ad from #64028 Co-authored-by: Petri-Johan Last <[email protected]>
1 parent d498442 commit a88bc4d

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

internal/extsvc/bitbucketcloud/client.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -210,7 +210,6 @@ func (c *client) reqPage(ctx context.Context, url string, results any) (*PageTok
210210
PageToken: &next,
211211
Values: results,
212212
})
213-
214213
if err != nil {
215214
return nil, err
216215
}
@@ -247,8 +246,9 @@ func (c *client) do(ctx context.Context, req *http.Request, result any) (code in
247246
// If we still don't succeed after waiting a total of 5 min, we give up.
248247
var resp *http.Response
249248
sleepTime := 10 * time.Second
249+
logger := log.Scoped("bitbucketcloud.Client")
250250
for {
251-
resp, err = oauthutil.DoRequest(ctx, nil, c.httpClient, req, c.Auth)
251+
resp, err = oauthutil.DoRequest(ctx, logger, c.httpClient, req, c.Auth)
252252
if resp != nil {
253253
code = resp.StatusCode
254254
}

0 commit comments

Comments
 (0)