From c9becdc9908f2a1961160837c6ab8cd9064e7854 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Fri, 27 Jun 2025 01:14:01 +0000 Subject: [PATCH 1/4] fix(pagination): check if page data is empty in GetNextPage --- packages/pagination/pagination.go | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/packages/pagination/pagination.go b/packages/pagination/pagination.go index db382e30..528cda8e 100644 --- a/packages/pagination/pagination.go +++ b/packages/pagination/pagination.go @@ -43,6 +43,9 @@ func (r *Page[T]) UnmarshalJSON(data []byte) error { // there is no next page, this function will return a 'nil' for the page value, but // will not return an error func (r *Page[T]) GetNextPage() (res *Page[T], err error) { + if len(r.Data) == 0 { + return nil, nil + } // This page represents a response that isn't actually paginated at the API level // so there will never be a next page. cfg := (*requestconfig.RequestConfig)(nil) @@ -137,6 +140,10 @@ func (r *CursorPage[T]) UnmarshalJSON(data []byte) error { // there is no next page, this function will return a 'nil' for the page value, but // will not return an error func (r *CursorPage[T]) GetNextPage() (res *CursorPage[T], err error) { + if len(r.Data) == 0 { + return nil, nil + } + if r.JSON.HasMore.Valid() && r.HasMore == false { return nil, nil } From 74ad0f8fab0f956234503a9ba26fbd395944dcf8 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Fri, 27 Jun 2025 16:41:24 +0000 Subject: [PATCH 2/4] fix: don't try to deserialize as json when ResponseBodyInto is []byte --- internal/requestconfig/requestconfig.go | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/internal/requestconfig/requestconfig.go b/internal/requestconfig/requestconfig.go index e93b9102..def7c58e 100644 --- a/internal/requestconfig/requestconfig.go +++ b/internal/requestconfig/requestconfig.go @@ -540,15 +540,15 @@ func (cfg *RequestConfig) Execute() (err error) { return nil } - // If the response happens to be a byte array, deserialize the body as-is. switch dst := cfg.ResponseBodyInto.(type) { + // If the response happens to be a byte array, deserialize the body as-is. case *[]byte: *dst = contents - } - - err = json.NewDecoder(bytes.NewReader(contents)).Decode(cfg.ResponseBodyInto) - if err != nil { - return fmt.Errorf("error parsing response json: %w", err) + default: + err = json.NewDecoder(bytes.NewReader(contents)).Decode(cfg.ResponseBodyInto) + if err != nil { + return fmt.Errorf("error parsing response json: %w", err) + } } return nil From ce45a7b05a76a3a0e9fc6463c17ee9fcf6e09488 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Fri, 27 Jun 2025 16:46:52 +0000 Subject: [PATCH 3/4] codegen metadata --- .stats.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.stats.yml b/.stats.yml index a5a45d72..ec540d8f 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,4 +1,4 @@ configured_endpoints: 97 openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/openai%2Fopenai-a473967d1766dc155994d932fbc4a5bcbd1c140a37c20d0a4065e1bf0640536d.yml openapi_spec_hash: 67cdc62b0d6c8b1de29b7dc54b265749 -config_hash: e74d6791681e3af1b548748ff47a22c2 +config_hash: 05c7d4a6f4d5983fe9550457114b47dd From c71f17a584f882ee2214736a6df4721577c579fa Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Fri, 27 Jun 2025 16:47:11 +0000 Subject: [PATCH 4/4] release: 1.8.2 --- .release-please-manifest.json | 2 +- CHANGELOG.md | 9 +++++++++ README.md | 2 +- internal/version.go | 2 +- 4 files changed, 12 insertions(+), 3 deletions(-) diff --git a/.release-please-manifest.json b/.release-please-manifest.json index 7e334b0f..262c3b74 100644 --- a/.release-please-manifest.json +++ b/.release-please-manifest.json @@ -1,3 +1,3 @@ { - ".": "1.8.1" + ".": "1.8.2" } \ No newline at end of file diff --git a/CHANGELOG.md b/CHANGELOG.md index da353bf6..16af7ff6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,14 @@ # Changelog +## 1.8.2 (2025-06-27) + +Full Changelog: [v1.8.1...v1.8.2](https://github.com/openai/openai-go/compare/v1.8.1...v1.8.2) + +### Bug Fixes + +* don't try to deserialize as json when ResponseBodyInto is []byte ([74ad0f8](https://github.com/openai/openai-go/commit/74ad0f8fab0f956234503a9ba26fbd395944dcf8)) +* **pagination:** check if page data is empty in GetNextPage ([c9becdc](https://github.com/openai/openai-go/commit/c9becdc9908f2a1961160837c6ab8cd9064e7854)) + ## 1.8.1 (2025-06-26) Full Changelog: [v1.8.0...v1.8.1](https://github.com/openai/openai-go/compare/v1.8.0...v1.8.1) diff --git a/README.md b/README.md index 6140bb90..897f4603 100644 --- a/README.md +++ b/README.md @@ -26,7 +26,7 @@ Or to pin the version: ```sh -go get -u 'github.com/openai/openai-go@v1.8.1' +go get -u 'github.com/openai/openai-go@v1.8.2' ``` diff --git a/internal/version.go b/internal/version.go index ab2ae2c9..c5df29ab 100644 --- a/internal/version.go +++ b/internal/version.go @@ -2,4 +2,4 @@ package internal -const PackageVersion = "1.8.1" // x-release-please-version +const PackageVersion = "1.8.2" // x-release-please-version