Skip to content

fix: correct exponential backoff by replacing XOR with bit shift#723

Open
m-iskw335 wants to merge 1 commit intogoogleapis:mainfrom
m-iskw335:fix/upload_retry
Open

fix: correct exponential backoff by replacing XOR with bit shift#723
m-iskw335 wants to merge 1 commit intogoogleapis:mainfrom
m-iskw335:fix/upload_retry

Conversation

@m-iskw335
Copy link
Copy Markdown

Description

  • Fixes a logical error in the exponential backoff calculation for file uploads by replacing the bitwise XOR operator with a bit shift.

Problem:

  • The retry logic currently uses the bitwise XOR operator (^), which is a logical error for exponential backoff in Go. This causes the retry delay to drop to 0 seconds on the third attempt.
With delayMultiplier = 2:

Attempt 0: 2 ^ 0 = 2
Attempt 1: 2 ^ 1 = 3
Attempt 2: 2 ^ 2 = 0

Solution

Replaced delayMultiplier^attempt with 1 << attempt to ensure proper exponential backoff (1s, 2s, 4s...).

@google-cla
Copy link
Copy Markdown

google-cla Bot commented Mar 17, 2026

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.

@Sivasankaran25 Sivasankaran25 self-assigned this Mar 17, 2026
@Sivasankaran25 Sivasankaran25 added the api:gemini-api Issues related to Gemini API label Mar 17, 2026
@m-iskw335
Copy link
Copy Markdown
Author

@Sivasankaran25
Just checking in to see if there’s anything else needed on my end to move this forward. Happy to help if there are any adjustments required!

@Sivasankaran25
Copy link
Copy Markdown
Collaborator

Sivasankaran25 commented Apr 15, 2026

@Sivasankaran25 Just checking in to see if there’s anything else needed on my end to move this forward. Happy to help if there are any adjustments required!

Thank you for bringing this to our attention. We truly appreciate you flagging this PR, we will file a internally.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

api:gemini-api Issues related to Gemini API

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants