From e453627323b65458f07c83e7a9581ff73d9ae515 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 27 Jan 2025 00:12:09 +0000 Subject: [PATCH] Bump google.golang.org/api from 0.217.0 to 0.218.0 Bumps [google.golang.org/api](https://github.com/googleapis/google-api-go-client) from 0.217.0 to 0.218.0. - [Release notes](https://github.com/googleapis/google-api-go-client/releases) - [Changelog](https://github.com/googleapis/google-api-go-client/blob/main/CHANGES.md) - [Commits](https://github.com/googleapis/google-api-go-client/compare/v0.217.0...v0.218.0) --- updated-dependencies: - dependency-name: google.golang.org/api dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- go.mod | 8 ++-- go.sum | 4 +- .../api/googleapi/googleapi.go | 38 ++++++++++++++----- .../api/internal/gensupport/resumable.go | 18 +++++++-- .../google.golang.org/api/internal/version.go | 2 +- vendor/modules.txt | 2 +- 6 files changed, 50 insertions(+), 22 deletions(-) diff --git a/go.mod b/go.mod index 117f8a4b2fc..1acd389ab81 100644 --- a/go.mod +++ b/go.mod @@ -33,7 +33,7 @@ require ( github.com/jsternberg/zap-logfmt v1.2.0 github.com/klauspost/compress v1.17.11 github.com/minio/minio-go/v7 v7.0.84 - github.com/mitchellh/mapstructure v1.5.1-0.20231216201459-8508981c8b6c + github.com/mitchellh/mapstructure v1.5.1-0.20231216201459-8508981c8b6c // indirect github.com/olekukonko/tablewriter v0.0.5 github.com/open-telemetry/opentelemetry-collector-contrib/pkg/translator/jaeger v0.118.0 github.com/opentracing-contrib/go-grpc v0.1.0 @@ -70,9 +70,9 @@ require ( go.uber.org/goleak v1.3.0 go.uber.org/multierr v1.11.0 go.uber.org/zap v1.27.0 - golang.org/x/sync v0.10.0 + golang.org/x/sync v0.10.0 // indirect golang.org/x/time v0.9.0 - google.golang.org/api v0.217.0 + google.golang.org/api v0.218.0 google.golang.org/grpc v1.69.4 google.golang.org/protobuf v1.36.3 gopkg.in/yaml.v2 v2.4.0 @@ -124,7 +124,6 @@ require ( go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp v1.34.0 go.opentelemetry.io/proto/otlp v1.5.0 golang.org/x/net v0.34.0 - golang.org/x/oauth2 v0.25.0 google.golang.org/genproto/googleapis/rpc v0.0.0-20250115164207-1a7da9e5054f ) @@ -359,6 +358,7 @@ require ( golang.org/x/crypto v0.32.0 // indirect golang.org/x/exp v0.0.0-20241108190413-2d47ceb2692f // indirect golang.org/x/mod v0.22.0 // indirect + golang.org/x/oauth2 v0.25.0 // indirect golang.org/x/sys v0.29.0 // indirect golang.org/x/text v0.21.0 // indirect golang.org/x/tools v0.27.0 // indirect diff --git a/go.sum b/go.sum index 507e303ce9b..b80eca02621 100644 --- a/go.sum +++ b/go.sum @@ -1441,8 +1441,8 @@ google.golang.org/api v0.24.0/go.mod h1:lIXQywCXRcnZPGlsd8NbLnOjtAoL6em04bJ9+z0M google.golang.org/api v0.28.0/go.mod h1:lIXQywCXRcnZPGlsd8NbLnOjtAoL6em04bJ9+z0MncE= google.golang.org/api v0.29.0/go.mod h1:Lcubydp8VUV7KeIHD9z2Bys/sm/vGKnG1UHuDBSrHWM= google.golang.org/api v0.30.0/go.mod h1:QGmEvQ87FHZNiUVJkT14jQNYJ4ZJjdRF23ZXz5138Fc= -google.golang.org/api v0.217.0 h1:GYrUtD289o4zl1AhiTZL0jvQGa2RDLyC+kX1N/lfGOU= -google.golang.org/api v0.217.0/go.mod h1:qMc2E8cBAbQlRypBTBWHklNJlaZZJBwDv81B1Iu8oSI= +google.golang.org/api v0.218.0 h1:x6JCjEWeZ9PFCRe9z0FBrNwj7pB7DOAqT35N+IPnAUA= +google.golang.org/api v0.218.0/go.mod h1:5VGHBAkxrA/8EFjLVEYmMUJ8/8+gWWQ3s4cFH0FxG2M= google.golang.org/appengine v1.1.0/go.mod h1:EbEs0AVv82hx2wNQdGPgUI5lhzA/G0D9YwlJXL52JkM= google.golang.org/appengine v1.4.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4= google.golang.org/appengine v1.5.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4= diff --git a/vendor/google.golang.org/api/googleapi/googleapi.go b/vendor/google.golang.org/api/googleapi/googleapi.go index 6818b2de304..c3e8a4f5911 100644 --- a/vendor/google.golang.org/api/googleapi/googleapi.go +++ b/vendor/google.golang.org/api/googleapi/googleapi.go @@ -145,22 +145,40 @@ func CheckResponse(res *http.Response) error { } slurp, err := io.ReadAll(res.Body) if err == nil { - jerr := new(errorReply) - err = json.Unmarshal(slurp, jerr) - if err == nil && jerr.Error != nil { - if jerr.Error.Code == 0 { - jerr.Error.Code = res.StatusCode - } - jerr.Error.Body = string(slurp) - jerr.Error.Header = res.Header - return jerr.Error - } + return CheckResponseWithBody(res, slurp) } return &Error{ Code: res.StatusCode, Body: string(slurp), Header: res.Header, } + +} + +// CheckResponseWithBody returns an error (of type *Error) if the response +// status code is not 2xx. Distinct from CheckResponse to allow for checking +// a previously-read body to maintain error detail content. +func CheckResponseWithBody(res *http.Response, body []byte) error { + if res.StatusCode >= 200 && res.StatusCode <= 299 { + return nil + } + + jerr := new(errorReply) + err := json.Unmarshal(body, jerr) + if err == nil && jerr.Error != nil { + if jerr.Error.Code == 0 { + jerr.Error.Code = res.StatusCode + } + jerr.Error.Body = string(body) + jerr.Error.Header = res.Header + return jerr.Error + } + + return &Error{ + Code: res.StatusCode, + Body: string(body), + Header: res.Header, + } } // IsNotModified reports whether err is the result of the diff --git a/vendor/google.golang.org/api/internal/gensupport/resumable.go b/vendor/google.golang.org/api/internal/gensupport/resumable.go index a87fd3e727b..d74fe2a2998 100644 --- a/vendor/google.golang.org/api/internal/gensupport/resumable.go +++ b/vendor/google.golang.org/api/internal/gensupport/resumable.go @@ -164,6 +164,8 @@ func (rx *ResumableUpload) transferChunk(ctx context.Context) (*http.Response, e // and calls the returned functions after the request returns (see send.go). // rx is private to the auto-generated API code. // Exactly one of resp or err will be nil. If resp is non-nil, the caller must call resp.Body.Close. +// Upload does not parse the response into the error on a non 200 response; +// it is the caller's responsibility to call resp.Body.Close. func (rx *ResumableUpload) Upload(ctx context.Context) (resp *http.Response, err error) { // There are a couple of cases where it's possible for err and resp to both @@ -256,6 +258,18 @@ func (rx *ResumableUpload) Upload(ctx context.Context) (resp *http.Response, err rCtx, cancel = context.WithTimeout(ctx, rx.ChunkTransferTimeout) } + // We close the response's body here, since we definitely will not + // return `resp` now. If we close it before the select case above, a + // timer may fire and cause us to return a response with a closed body + // (in which case, the caller will not get the error message in the body). + if resp != nil && resp.Body != nil { + // Read the body to EOF - if the Body is not both read to EOF and closed, + // the Client's underlying RoundTripper may not be able to re-use the + // persistent TCP connection to the server for a subsequent "keep-alive" request. + // See https://pkg.go.dev/net/http#Client.Do + io.Copy(io.Discard, resp.Body) + resp.Body.Close() + } resp, err = rx.transferChunk(rCtx) var status int @@ -282,15 +296,11 @@ func (rx *ResumableUpload) Upload(ctx context.Context) (resp *http.Response, err rx.attempts++ pause = bo.Pause() - if resp != nil && resp.Body != nil { - resp.Body.Close() - } } // If the chunk was uploaded successfully, but there's still // more to go, upload the next chunk without any delay. if statusResumeIncomplete(resp) { - resp.Body.Close() continue } diff --git a/vendor/google.golang.org/api/internal/version.go b/vendor/google.golang.org/api/internal/version.go index d31a991e4e7..e55b0e5b710 100644 --- a/vendor/google.golang.org/api/internal/version.go +++ b/vendor/google.golang.org/api/internal/version.go @@ -5,4 +5,4 @@ package internal // Version is the current tagged release of the library. -const Version = "0.217.0" +const Version = "0.218.0" diff --git a/vendor/modules.txt b/vendor/modules.txt index c22bd6f1841..0faa5b6cd42 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -2003,7 +2003,7 @@ gonum.org/v1/gonum/lapack gonum.org/v1/gonum/lapack/gonum gonum.org/v1/gonum/lapack/lapack64 gonum.org/v1/gonum/mat -# google.golang.org/api v0.217.0 +# google.golang.org/api v0.218.0 ## explicit; go 1.22 google.golang.org/api/googleapi google.golang.org/api/googleapi/transport