Skip to content

Commit 419dd89

Browse files
speedstorm1copybara-github
authored andcommitted
fix: honor an explicit zero in HttpRetryOptions delay fields
fixes #2026 PiperOrigin-RevId: 1003523084
1 parent 380733f commit 419dd89

5 files changed

Lines changed: 26 additions & 30 deletions

File tree

‎CHANGELOG.md‎

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,5 @@
11
# Changelog
22

3-
## [2.32.0](https://github.com/googleapis/python-genai/compare/v2.31.0...v2.32.0) (2026-10-21)
4-
5-
6-
### Features
7-
8-
* Add base_voice to PromptedVoice in GAOS SDK ([5488643](https://github.com/googleapis/python-genai/commit/548864370ee9c88de0bd839b619dc05bcb7085e7))
9-
* Add generation_output_config to GenerateContentConfig ([5c008e1](https://github.com/googleapis/python-genai/commit/5c008e14b9c9fdecbaf61eb53ad7c09f57fa5f8a))
10-
* Add Live API in-session context updates (`send_context_update`) and types across GenAI SDKs. ([364889a](https://github.com/googleapis/python-genai/commit/364889aafe40bfa8f3b9db847ba272d299f7d632))
11-
* **sdks:** Enable `fixes.openSingleValueEnumsOct2026` across all SDKs ([78f6d34](https://github.com/googleapis/python-genai/commit/78f6d3412caaaed44f99ce57be2d16d0b8c407cb))
12-
* Update discovery doc ([6cd176e](https://github.com/googleapis/python-genai/commit/6cd176e135a188bbb0d0f9afca520e7d6483823d))
13-
14-
15-
### Bug Fixes
16-
17-
* Base64-encode inline bytes in Live send_tool_response ([a7bbff6](https://github.com/googleapis/python-genai/commit/a7bbff6e73fa9444802cd9a17e8c94e30341bf5d)), refs [#3022](https://github.com/googleapis/python-genai/issues/3022)
18-
* Don't crash parsing responses with JSON objects in `Any`-typed fields ([4c1abcc](https://github.com/googleapis/python-genai/commit/4c1abccf258c9247218e66610790043893cd6950))
19-
* **interactions:** Sync InteractionSseEventInteractionStatus enum with InteractionStatus ([ba854b2](https://github.com/googleapis/python-genai/commit/ba854b2d29a3ff0d4758da886edabb458726b210))
20-
21-
22-
### Documentation
23-
24-
* Publish the API reference on each release ([1d12358](https://github.com/googleapis/python-genai/commit/1d12358a1398b9a510ae8ba25dd31e746d8e9be9))
25-
* Transition docs workflow to GitHub Actions ([3b1256a](https://github.com/googleapis/python-genai/commit/3b1256ac5f4b8c49a469ca307ca765185184774d))
26-
273
## [2.31.0](https://github.com/googleapis/python-genai/compare/v2.30.1...v2.31.0) (2026-10-14)
284

295

‎google/genai/_api_client.py‎

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -609,6 +609,11 @@ def _load_json_from_response(cls, response: Any) -> Any:
609609
)
610610

611611

612+
def _delay_or_default(value: Optional[float], default: float) -> float:
613+
"""Returns the default only when the field is unset, so 0.0 is honored."""
614+
return default if value is None else value
615+
616+
612617
def retry_args(options: Optional[HttpRetryOptions]) -> _common.StringDict:
613618
"""Returns the retry args for the given http retry options.
614619
@@ -630,10 +635,10 @@ def retry_args(options: Optional[HttpRetryOptions]) -> _common.StringDict:
630635
or isinstance(e, _HTTPX_TRANSIENT_EXC),
631636
)
632637
wait = tenacity.wait_exponential_jitter(
633-
initial=options.initial_delay or _RETRY_INITIAL_DELAY,
634-
max=options.max_delay or _RETRY_MAX_DELAY,
635-
exp_base=options.exp_base or _RETRY_EXP_BASE,
636-
jitter=options.jitter or _RETRY_JITTER,
638+
initial=_delay_or_default(options.initial_delay, _RETRY_INITIAL_DELAY),
639+
max=_delay_or_default(options.max_delay, _RETRY_MAX_DELAY),
640+
exp_base=_delay_or_default(options.exp_base, _RETRY_EXP_BASE),
641+
jitter=_delay_or_default(options.jitter, _RETRY_JITTER),
637642
)
638643
return {
639644
'stop': stop,

‎google/genai/tests/client/test_retries.py‎

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -187,6 +187,21 @@ def test_retry_args_enabled_with_custom_values_are_not_overridden():
187187
assert not retry.predicate(e)
188188

189189

190+
def test_retry_args_explicit_zero_values_are_not_overridden():
191+
# A field set to 0.0 is specified, so it must reach tenacity instead of
192+
# falling back to the default.
193+
options = types.HttpRetryOptions(
194+
initial_delay=0.0, max_delay=0.0, exp_base=0.0, jitter=0.0
195+
)
196+
197+
wait = api_client.retry_args(options)['wait']
198+
199+
assert wait.jitter == 0.0
200+
assert wait.initial == 0.0
201+
assert wait.max == 0.0
202+
assert wait.exp_base == 0.0
203+
204+
190205
def test_retry_args_retries_httpx_transport_errors():
191206
# httpx transport errors (timeouts, connect errors) bypass APIError but are
192207
# transient infrastructure failures, so the predicate must still retry them

‎google/genai/version.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,4 +13,4 @@
1313
# limitations under the License.
1414
#
1515

16-
__version__ = '2.32.0' # x-release-please-version
16+
__version__ = '2.31.0' # x-release-please-version

‎pyproject.toml‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ requires = ["setuptools", "wheel", "twine>=6.1.0", "packaging>=24.2", "pkginfo>=
33

44
[project]
55
name = "google-genai"
6-
version = "2.32.0"
6+
version = "2.31.0"
77
description = "GenAI Python SDK"
88
readme = "README.md"
99
license = "Apache-2.0"

0 commit comments

Comments
 (0)