Skip to content

fix(Storage): ensure StorageClient retryStrategy is applied correctly to all operations - #9516

Open
salilg-eng wants to merge 1 commit into
googleapis:mainfrom
salilg-eng:fix/storage-retry-bug
Open

fix(Storage): ensure StorageClient retryStrategy is applied correctly to all operations#9516
salilg-eng wants to merge 1 commit into
googleapis:mainfrom
salilg-eng:fix/storage-retry-bug

Conversation

@salilg-eng

Copy link
Copy Markdown
Contributor

Fixes #9334

The Problem:
When creating a StorageClient with a custom retryStrategy (like StorageClient::RETRY_ALWAYS), the strategy was being ignored for non-idempotent operations like deleting an object.

This happened because in Rest::send and Rest::headObject, the retry function (getRestRetryFunction) was being constructed before the client's retryStrategy was added to the request options. Due to this order of execution, it fell back to the default StorageClient::RETRY_IDEMPOTENT.

The Solution:

Moved the $options['retryStrategy'] ??= $this->retryStrategy; assignment up so it happens before getRestRetryFunction is called.
Added a new unit test (testAlwaysRetryStrategyWithNonIdempotentOpSuccessful) to verify that a non-idempotent operation (like delete) correctly respects RETRY_ALWAYS.
(Note: The previous test for this feature used createBucket, which is idempotent and always retries by default, which is why this bug slipped through initially).

@salilg-eng
salilg-eng requested review from a team as code owners August 20, 2026 06:47
@product-auto-label product-auto-label Bot added the api: storage Issues related to the Cloud Storage API. label Aug 20, 2026
@google-cla

google-cla Bot commented Aug 20, 2026

Copy link
Copy Markdown

Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

View this failed invocation of the CLA check for more information.

For the most up to date status, view the checks section at the bottom of the pull request.

@Hectorhammett

Copy link
Copy Markdown
Collaborator

Hello @salilg-eng!

It seems like there are two different accounts in the commit history and it is detecting it as a non googler contribution, asking you to sign the CLA.

Why is there a "actions-user" account in two of the commits?

If we want to fix it, to my understanding we need to have only an approved account to be able to merge this :).

Comment thread Storage/tests/Unit/StorageClientTest.php
Comment thread Storage/tests/System/StorageTestCase.php Outdated
@salilg-eng
salilg-eng force-pushed the fix/storage-retry-bug branch from 44507df to 5feeb56 Compare August 24, 2026 05:32
@salilg-eng
salilg-eng force-pushed the fix/storage-retry-bug branch from 85996f0 to 8451f26 Compare August 27, 2026 03:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

api: storage Issues related to the Cloud Storage API.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

StorageClient::send does not use the client's retryStrategy correctly

3 participants