Skip to content

Database governance built for humans and agents — controlling changes and access across every major database.

refactor: renovate requester (#11422)

Danny Xu6588d945ae7c
diff --git a/backend/plugin/vcs/azure/azure.go b/backend/plugin/vcs/azure/azure.go
index f442956a2d..0629d3ae63 100644
--- a/backend/plugin/vcs/azure/azure.go
+++ b/backend/plugin/vcs/azure/azure.go
@@ -27,14 +27,12 @@ var _ vcs.Provider = (*Provider)(nil)
// Provider is a Azure DevOps VCS provider.
type Provider struct {
- client *http.Client
instanceURL string
authToken string
}
func newProvider(config vcs.ProviderConfig) vcs.Provider {
return &Provider{
- client: &http.Client{},
instanceURL: config.InstanceURL,
authToken: config.AuthToken,
}
@@ -167,7 +165,6 @@ type ChangesResponse struct {
// Docs: https://learn.microsoft.com/en-us/rest/api/azure/devops/git/commits/get-changes?view=azure-devops-rest-7.0&tabs=HTTP
// TODO(zp): We should GET the changes pagenated, otherwise it may hit the Azure DevOps API limit.
func (p *Provider) getChangesByCommit(ctx context.Context, externalRepositoryID, commitID string) (*ChangesResponse, error) {
- client := &http.Client{}
apiURL, err := getRepositoryAPIURL(externalRepositoryID)
if err != nil {
return nil, err
@@ -176,7 +173,7 @@ func (p *Provider) getChangesByCommit(ctx context.Context, externalRepositoryID,
values := &url.Values{}
values.Set("api-version", "7.0")
url := fmt.Sprintf("%s/commits/%s/changes?%s", apiURL, url.PathEscape(commitID), values.Encode())
- code, _, body, err := internal.Get(ctx, client, url, p.authToken)
+ code, body, err := internal.Get(ctx, url, p.authToken)
if err != nil {
return nil, errors.Wrapf(err, "GET %s", url)
}
@@ -234,7 +231,7 @@ func (p *Provider) FetchAllRepositoryList(ctx context.Context) ([]*vcs.Repositor
for _, organization := range organizations {
if err := func() error {
url := fmt.Sprintf("https://dev.azure.com/%s/_apis/git/repositories?%s", url.PathEscape(organization), urlParams.Encode())
- code, _, body, err := internal.Get(ctx, p.client, url, p.authToken)
+ code, body, err := internal.Get(ctx, url, p.authToken)
if err != nil {
return errors.Wrapf(err, "GET %s", url)
}
@@ -289,7 +286,7 @@ func (p *Provider) getAuthenticatedProfilePublicAlias(ctx context.Context) (stri
values.Set("api-version", "7.0")
url := fmt.Sprintf("https://app.vssps.visualstudio.com/_apis/profile/profiles/me?%s", values.Encode())
- code, _, body, err := internal.Get(ctx, p.client, url, p.authToken)
+ code, body, err := internal.Get(ctx, url, p.authToken)
if err != nil {
return "", errors.Wrapf(err, "GET %s", url)
}
@@ -318,7 +315,7 @@ func (p *Provider) listOrganizationsForMember(ctx context.Context, memberID stri
urlParams.Set("api-version", "7.0")
url := fmt.Sprintf("https://app.vssps.visualstudio.com/_apis/accounts?%s", urlParams.Encode())
- code, _, body, err := internal.Get(ctx, p.client, url, p.authToken)
+ code, body, err := internal.Get(ctx, url, p.authToken)
if err != nil {
return nil, errors.Wrapf(err, "GET %s", url)
}
@@ -377,7 +374,7 @@ func (p *Provider) ReadFileContent(ctx context.Context, repositoryID, filePath s
values.Set("versionDescriptor.version", refInfo.RefName)
url := fmt.Sprintf("%s/items?%s", apiURL, values.Encode())
- code, _, body, err := internal.Get(ctx, p.client, url, p.authToken)
+ code, body, err := internal.Get(ctx, url, p.authToken)
if err != nil {
return "", errors.Wrapf(err, "GET %s", url)
}
@@ -409,7 +406,7 @@ func (p *Provider) GetBranch(ctx context.Context, repositoryID, branchName strin
urlParams.Set("api-version", "7.0")
url := fmt.Sprintf("%s/stats/branches?%s", apiURL, urlParams.Encode())
- code, _, body, err := internal.Get(ctx, p.client, url, p.authToken)
+ code, body, err := internal.Get(ctx, url, p.authToken)
if err != nil {
return nil, errors.Wrapf(err, "GET %s", url)
}
@@ -455,12 +452,7 @@ func (p *Provider) ListPullRequestFile(ctx context.Context, repositoryID, pullRe
urlParams.Set("api-version", "7.0")
url := fmt.Sprintf("%s/pullrequests/%s?%s", apiURL, pullRequestID, urlParams.Encode())
- code, _, resp, err := internal.Get(
- ctx,
- p.client,
- url,
- p.authToken,
- )
+ code, resp, err := internal.Get(ctx, url, p.authToken)
if err != nil {
return nil, errors.Wrapf(err, "GET %s", url)
}
@@ -505,13 +497,7 @@ func (p *Provider) CreateWebhook(ctx context.Context, externalRepositoryID strin
urlParams := &url.Values{}
urlParams.Set("api-version", "7.0")
url := fmt.Sprintf("https://dev.azure.com/%s/_apis/hooks/subscriptions?%s", url.PathEscape(organizationName), urlParams.Encode())
- code, _, body, err := internal.Post(
- ctx,
- p.client,
- url,
- p.authToken,
- payload,
- )
+ code, body, err := internal.Post(ctx, url, p.authToken, payload)
if err != nil {
return "", errors.Wrapf(err, "failed to create webhook")
}
@@ -544,12 +530,7 @@ func (p *Provider) DeleteWebhook(ctx context.Context, _, webhookID string) error
values.Set("api-version", "7.0")
url := fmt.Sprintf("https://dev.azure.com/%s/_apis/hooks/subscriptions/%s?%s", url.PathEscape(organizationName), url.PathEscape(webhookID), values.Encode())
- code, _, body, err := internal.Delete(
- ctx,
- p.client,
- url,
- p.authToken,
- )
+ code, body, err := internal.Delete(ctx, url, p.authToken)
if err != nil {
return errors.Wrapf(err, "failed to send delete webhook request")
}
diff --git a/backend/plugin/vcs/bitbucket/bitbucket.go b/backend/plugin/vcs/bitbucket/bitbucket.go
index faadb1de95..698e06f80a 100644
--- a/backend/plugin/vcs/bitbucket/bitbucket.go
+++ b/backend/plugin/vcs/bitbucket/bitbucket.go
@@ -90,12 +90,7 @@ type CommitDiffStat struct {
}
func (p *Provider) fetchPaginatedDiffFileList(ctx context.Context, url string) (diffs []*CommitDiffStat, next string, err error) {
- code, _, body, err := internal.Get(
- ctx,
- p.client,
- url,
- p.authToken,
- )
+ code, body, err := internal.Get(ctx, url, p.authToken)
if err != nil {
return nil, "", errors.Wrapf(err, "GET %s", url)
}
@@ -172,12 +167,7 @@ func (p *Provider) FetchAllRepositoryList(ctx context.Context) ([]*vcs.Repositor
// the paginated results along with a string indicating the URL of the next page
// (if exists).
func (p *Provider) fetchPaginatedRepositoryList(ctx context.Context, url string) (repos []*Repository, next string, err error) {
- code, _, body, err := internal.Get(
- ctx,
- p.client,
- url,
- p.authToken,
- )
+ code, body, err := internal.Get(ctx, url, p.authToken)
if err != nil {
return nil, "", errors.Wrapf(err, "GET %s", url)
}
@@ -218,12 +208,7 @@ func (p *Provider) fetchPaginatedRepositoryList(ctx context.Context, url string)
// Docs: https://developer.atlassian.com/cloud/bitbucket/rest/api-group-source/#raw-file-contents
func (p *Provider) ReadFileContent(ctx context.Context, repositoryID, filePath string, refInfo vcs.RefInfo) (string, error) {
url := fmt.Sprintf("%s/repositories/%s/src/%s/%s", p.APIURL(p.instanceURL), repositoryID, url.PathEscape(refInfo.RefName), url.PathEscape(filePath))
- code, _, body, err := internal.Get(
- ctx,
- p.client,
- url,
- p.authToken,
- )
+ code, body, err := internal.Get(ctx, url, p.authToken)
if err != nil {
return "", errors.Wrapf(err, "GET %s", url)
}
@@ -257,12 +242,7 @@ type Branch struct {
// Docs: https://developer.atlassian.com/cloud/bitbucket/rest/api-group-refs/#api-repositories-workspace-repo-slug-refs-branches-name-get
func (p *Provider) GetBranch(ctx context.Context, repositoryID, branchName string) (*vcs.BranchInfo, error) {
url := fmt.Sprintf("%s/repositories/%s/refs/branches/%s", p.APIURL(p.instanceURL), repositoryID, branchName)
- code, _, body, err := internal.Get(
- ctx,
- p.client,
- url,
- p.authToken,
- )
+ code, body, err := internal.Get(ctx, url, p.authToken)
if err != nil {
return nil, errors.Wrapf(err, "GET %s", url)
}
@@ -394,13 +374,7 @@ type Webhook struct {
// Docs: https://developer.atlassian.com/cloud/bitbucket/rest/api-group-repositories/#api-repositories-workspace-repo-slug-hooks-post
func (p *Provider) CreateWebhook(ctx context.Context, repositoryID string, payload []byte) (string, error) {
url := fmt.Sprintf("%s/repositories/%s/hooks", p.APIURL(p.instanceURL), repositoryID)
- code, _, body, err := internal.Post(
- ctx,
- p.client,
- url,
- p.authToken,
- payload,
- )
+ code, body, err := internal.Post(ctx, url, p.authToken, payload)
if err != nil {
return "", errors.Wrapf(err, "POST %s", url)
}
@@ -431,12 +405,7 @@ func (p *Provider) CreateWebhook(ctx context.Context, repositoryID string, paylo
// Docs: https://developer.atlassian.com/cloud/bitbucket/rest/api-group-repositories/#api-repositories-workspace-repo-slug-hooks-uid-delete
func (p *Provider) DeleteWebhook(ctx context.Context, repositoryID, webhookID string) error {
url := fmt.Sprintf("%s/repositories/%s/hooks/%s", p.APIURL(p.instanceURL), repositoryID, webhookID)
- code, _, body, err := internal.Delete(
- ctx,
- p.client,
- url,
- p.authToken,
- )
+ code, body, err := internal.Delete(ctx, url, p.authToken)
if err != nil {
return errors.Wrapf(err, "DELETE %s", url)
}
diff --git a/backend/plugin/vcs/github/github.go b/backend/plugin/vcs/github/github.go
index c5d5f9a8de..8ddfa50544 100644
--- a/backend/plugin/vcs/github/github.go
+++ b/backend/plugin/vcs/github/github.go
@@ -188,12 +188,7 @@ func (p *Provider) FetchAllRepositoryList(ctx context.Context) ([]*vcs.Repositor
// with a boolean indicating whether the next page exists.
func (p *Provider) fetchPaginatedRepositoryList(ctx context.Context, page int) (repos []Repository, hasNextPage bool, err error) {
url := fmt.Sprintf("%s/user/repos?page=%d&per_page=%d", p.APIURL(p.instanceURL), page, apiPageSize)
- code, _, body, err := internal.Get(
- ctx,
- p.client,
- url,
- p.authToken,
- )
+ code, body, err := internal.Get(ctx, url, p.authToken)
if err != nil {
return nil, false, errors.Wrapf(err, "GET %s", url)
}
@@ -225,11 +220,7 @@ func (p *Provider) fetchPaginatedRepositoryList(ctx context.Context, page int) (
// Docs: https://docs.github.com/en/rest/repos/contents#get-repository-content
func (p *Provider) ReadFileContent(ctx context.Context, repositoryID, filePath string, refInfo vcs.RefInfo) (string, error) {
url := fmt.Sprintf("%s/repos/%s/contents/%s?ref=%s", p.APIURL(p.instanceURL), repositoryID, url.QueryEscape(filePath), refInfo.RefName)
- code, _, body, err := internal.GetWithHeader(
- ctx,
- p.client,
- url,
- p.authToken,
+ code, body, err := internal.GetWithHeader(ctx, url, p.authToken,
map[string]string{
"Accept": "application/vnd.github.raw",
},
@@ -321,12 +312,7 @@ func (p *Provider) ListPullRequestFile(ctx context.Context, repositoryID, pullRe
// listPaginatedPullRequestFile lists the changed files in the pull request with pagination.
func (p *Provider) listPaginatedPullRequestFile(ctx context.Context, repositoryID, pullRequestID string, page int) ([]PullRequestFile, error) {
requestURL := fmt.Sprintf("%s/repos/%s/pulls/%s/files?per_page=%d&page=%d", p.APIURL(p.instanceURL), repositoryID, pullRequestID, apiPageSize, page)
- code, _, body, err := internal.Get(
- ctx,
- p.client,
- requestURL,
- p.authToken,
- )
+ code, body, err := internal.Get(ctx, requestURL, p.authToken)
if err != nil {
return nil, errors.Wrapf(err, "GET %s", requestURL)
}
@@ -369,12 +355,7 @@ type ReferenceObject struct {
// Docs: https://docs.github.com/en/rest/git/refs#get-a-reference
func (p *Provider) GetBranch(ctx context.Context, repositoryID, branchName string) (*vcs.BranchInfo, error) {
url := fmt.Sprintf("%s/repos/%s/git/ref/heads/%s", p.APIURL(p.instanceURL), repositoryID, branchName)
- code, _, body, err := internal.Get(
- ctx,
- p.client,
- url,
- p.authToken,
- )
+ code, body, err := internal.Get(ctx, url, p.authToken)
if err != nil {
return nil, errors.Wrapf(err, "GET %s", url)
}
@@ -415,13 +396,7 @@ type PullRequest struct {
// Docs: https://docs.github.com/en/rest/webhooks/repos#create-a-repository-webhook
func (p *Provider) CreateWebhook(ctx context.Context, repositoryID string, payload []byte) (string, error) {
url := fmt.Sprintf("%s/repos/%s/hooks", p.APIURL(p.instanceURL), repositoryID)
- code, _, body, err := internal.Post(
- ctx,
- p.client,
- url,
- p.authToken,
- payload,
- )
+ code, body, err := internal.Post(ctx, url, p.authToken, payload)
if err != nil {
return "", errors.Wrapf(err, "POST %s", url)
}
@@ -452,12 +427,7 @@ func (p *Provider) CreateWebhook(ctx context.Context, repositoryID string, paylo
// Docs: https://docs.github.com/en/rest/webhooks/repos#delete-a-repository-webhook
func (p *Provider) DeleteWebhook(ctx context.Context, repositoryID, webhookID string) error {
url := fmt.Sprintf("%s/repos/%s/hooks/%s", p.APIURL(p.instanceURL), repositoryID, webhookID)
- code, _, body, err := internal.Delete(
- ctx,
- p.client,
- url,
- p.authToken,
- )
+ code, body, err := internal.Delete(ctx, url, p.authToken)
if err != nil {
return errors.Wrapf(err, "DELETE %s", url)
}
diff --git a/backend/plugin/vcs/gitlab/gitlab.go b/backend/plugin/vcs/gitlab/gitlab.go
index 4805765dbc..7441caf98d 100644
--- a/backend/plugin/vcs/gitlab/gitlab.go
+++ b/backend/plugin/vcs/gitlab/gitlab.go
@@ -204,12 +204,7 @@ func (p *Provider) fetchPaginatedRepositoryList(ctx context.Context, page int) (
// We will use user's token to create webhook in the project, which requires the
// token owner to be at least the project maintainer(40).
url := fmt.Sprintf("%s/projects?membership=true&simple=true&min_access_level=40&page=%d&per_page=%d", p.APIURL(p.instanceURL), page, apiPageSize)
- code, _, body, err := internal.Get(
- ctx,
- p.client,
- url,
- p.authToken,
- )
+ code, body, err := internal.Get(ctx, url, p.authToken)
if err != nil {
return nil, false, errors.Wrapf(err, "GET %s", url)
}
@@ -267,12 +262,7 @@ type MergeRequestFile struct {
// Docs: https://docs.gitlab.com/ee/api/merge_requests.html#get-single-mr-changes
func (p *Provider) ListPullRequestFile(ctx context.Context, repositoryID, pullRequestID string) ([]*vcs.PullRequestFile, error) {
url := fmt.Sprintf("%s/projects/%s/merge_requests/%s/changes", p.APIURL(p.instanceURL), repositoryID, pullRequestID)
- code, _, body, err := internal.Get(
- ctx,
- p.client,
- url,
- p.authToken,
- )
+ code, body, err := internal.Get(ctx, url, p.authToken)
if err != nil {
return nil, errors.Wrapf(err, "GET %s", url)
}
@@ -329,12 +319,7 @@ type MergeRequestCreate struct {
// Docs: https://docs.gitlab.com/ee/api/branches.html#get-single-repository-branch
func (p *Provider) GetBranch(ctx context.Context, repositoryID, branchName string) (*vcs.BranchInfo, error) {
url := fmt.Sprintf("%s/projects/%s/repository/branches/%s", p.APIURL(p.instanceURL), repositoryID, branchName)
- code, _, body, err := internal.Get(
- ctx,
- p.client,
- url,
- p.authToken,
- )
+ code, body, err := internal.Get(ctx, url, p.authToken)
if err != nil {
return nil, errors.Wrapf(err, "GET %s", url)
}
@@ -370,13 +355,7 @@ type MergeRequest struct {
// Docs: https://docs.gitlab.com/ee/api/projects.html#add-project-hook
func (p *Provider) CreateWebhook(ctx context.Context, repositoryID string, payload []byte) (string, error) {
url := fmt.Sprintf("%s/projects/%s/hooks", p.APIURL(p.instanceURL), repositoryID)
- code, _, body, err := internal.Post(
- ctx,
- p.client,
- url,
- p.authToken,
- payload,
- )
+ code, body, err := internal.Post(ctx, url, p.authToken, payload)
if err != nil {
return "", errors.Wrapf(err, "POST %s", url)
}
@@ -412,12 +391,7 @@ func (p *Provider) CreateWebhook(ctx context.Context, repositoryID string, paylo
// Docs: https://docs.gitlab.com/ee/api/projects.html#delete-project-hook
func (p *Provider) DeleteWebhook(ctx context.Context, repositoryID, webhookID string) error {
url := fmt.Sprintf("%s/projects/%s/hooks/%s", p.APIURL(p.instanceURL), repositoryID, webhookID)
- code, _, body, err := internal.Delete(
- ctx,
- p.client,
- url,
- p.authToken,
- )
+ code, body, err := internal.Delete(ctx, url, p.authToken)
if err != nil {
return errors.Wrapf(err, "DELETE %s", url)
}
@@ -443,12 +417,7 @@ func (p *Provider) readFile(ctx context.Context, repositoryID, filePath string,
// In such cases, the HTTP header "Content-Encoding" will, for example, be changed to "gzip" and makes the value of "Content-Length" untrustworthy.
// We can avoid dealing with this type of problem by using the raw API instead of the typical JSON API.
url := fmt.Sprintf("%s/projects/%s/repository/files/%s/raw?ref=%s", p.APIURL(p.instanceURL), repositoryID, url.QueryEscape(filePath), url.QueryEscape(refInfo.RefName))
- code, _, body, err := internal.Get(
- ctx,
- p.client,
- url,
- p.authToken,
- )
+ code, body, err := internal.Get(ctx, url, p.authToken)
if err != nil {
return nil, errors.Wrapf(err, "GET %s", url)
}
diff --git a/backend/plugin/vcs/internal/request.go b/backend/plugin/vcs/internal/request.go
index 5212ce4924..2dce05b781 100644
--- a/backend/plugin/vcs/internal/request.go
+++ b/backend/plugin/vcs/internal/request.go
@@ -6,95 +6,52 @@ import (
"context"
"fmt"
"io"
- "log/slog"
"net/http"
"github.com/pkg/errors"
-
- "github.com/bytebase/bytebase/backend/common/log"
)
-// Post makes a HTTP POST request to the given URL using the token. It refreshes
-// token and retries the request in the case of the token has expired.
-func Post(ctx context.Context, client *http.Client, url string, token string, body []byte) (code int, header http.Header, respBody string, err error) {
- //nolint:bodyclose
- return retry(ctx, requesterWithHeader(ctx, client, http.MethodPost, url, token, bytes.NewReader(body), nil))
+// Post makes a HTTP POST request to the given URL using the token.
+func Post(ctx context.Context, url string, token string, body []byte) (code int, respBody string, err error) {
+ return request(ctx, http.MethodPost, url, token, nil, bytes.NewReader(body))
}
-// Get makes a HTTP GET request to the given URL using the token. It refreshes
-// token and retries the request in the case of the token has expired.
-func Get(ctx context.Context, client *http.Client, url string, token string) (code int, header http.Header, respBody string, err error) {
- //nolint:bodyclose
- return retry(ctx, requesterWithHeader(ctx, client, http.MethodGet, url, token, nil, nil))
+// Get makes a HTTP GET request to the given URL using the token.
+func Get(ctx context.Context, url string, token string) (code int, respBody string, err error) {
+ return request(ctx, http.MethodGet, url, token, nil, bytes.NewReader(nil))
}
-// GetWithHeader makes a HTTP GET request to the given URL using the token and
-// additional header. It refreshes token and retries the request in the case of
-// the token has expired.
-func GetWithHeader(ctx context.Context, client *http.Client, url string, token string, header map[string]string) (code int, _ http.Header, respBody string, err error) {
- //nolint:bodyclose
- return retry(ctx, requesterWithHeader(ctx, client, http.MethodGet, url, token, nil, header))
+// GetWithHeader makes a HTTP GET request to the given URL using the token and additional header.
+func GetWithHeader(ctx context.Context, url string, token string, header map[string]string) (code int, respBody string, err error) {
+ return request(ctx, http.MethodGet, url, token, header, bytes.NewReader(nil))
}
-// Delete makes a HTTP DELETE request to the given URL using the token. It refreshes
-// token and retries the request in the case of the token has expired.
-func Delete(ctx context.Context, client *http.Client, url string, token string) (code int, header http.Header, respBody string, err error) {
- //nolint:bodyclose
- return retry(ctx, requesterWithHeader(ctx, client, http.MethodDelete, url, token, nil, nil))
+// Delete makes a HTTP DELETE request to the given URL using the token.
+func Delete(ctx context.Context, url string, token string) (code int, respBody string, err error) {
+ return request(ctx, http.MethodDelete, url, token, nil, bytes.NewReader(nil))
}
-func requesterWithHeader(ctx context.Context, client *http.Client, method, url string, token string, body io.Reader, header map[string]string) func() (*http.Response, error) {
- // The body may be read multiple times but io.Reader is meant to be read once,
- // so we read the body first and build the reader every time.
- var bodyBytes []byte
- if body != nil {
- b, err := io.ReadAll(body)
- if err != nil {
- return func() (*http.Response, error) {
- return nil, errors.Wrap(err, "failed to read from body")
- }
- }
- bodyBytes = b
+func request(ctx context.Context, method, url string, token string, header map[string]string, requestBody *bytes.Reader) (int, string, error) {
+ req, err := http.NewRequestWithContext(ctx, method, url, requestBody)
+ if err != nil {
+ return 0, "", errors.Wrapf(err, "failed to build delete request for url %s", url)
}
- return func() (*http.Response, error) {
- req, err := http.NewRequestWithContext(ctx, method, url, bytes.NewReader(bodyBytes))
- if err != nil {
- return nil, errors.Wrapf(err, "construct %s %s", method, url)
- }
-
- req.Header.Set("Content-Type", "application/json")
- req.Header.Add("Authorization", fmt.Sprintf("Bearer %s", token))
- for k, v := range header {
- req.Header.Set(k, v)
- }
-
- resp, err := client.Do(req)
- if err != nil {
- return nil, errors.Wrapf(err, "%s %s", method, url)
- }
- return resp, nil
+ req.Header.Set("Content-Type", "application/json")
+ req.Header.Add("Authorization", fmt.Sprintf("Bearer %s", token))
+ for k, v := range header {
+ req.Header.Set(k, v)
}
-}
-
-func retry(ctx context.Context, f func() (*http.Response, error)) (code int, header http.Header, respBody string, err error) {
- // TODO(d): handle timeout retries.
- select {
- case <-ctx.Done():
- return 0, nil, "", ctx.Err()
- default:
- }
-
- resp, err := f()
+ client := &http.Client{}
+ resp, err := client.Do(req)
if err != nil {
- return 0, nil, "", err
+ return 0, "", errors.Wrapf(err, "failed to send delete request for url %s", url)
}
-
- body, err := io.ReadAll(resp.Body)
+ respBody, err := io.ReadAll(resp.Body)
if err != nil {
- return 0, nil, "", errors.Wrapf(err, "read response body with status code %d", resp.StatusCode)
+ return 0, "", errors.Wrapf(err, "read delete %s response body with status code %d", url, resp.StatusCode)
}
if err := resp.Body.Close(); err != nil {
- slog.Warn("failed to close resp body", log.BBError(err))
+ return 0, "", errors.Wrapf(err, "failed to close delete %s response body with status code %d", url, resp.StatusCode)
}
- return resp.StatusCode, resp.Header, string(body), nil
+ return resp.StatusCode, string(respBody), nil
}