Skip to content

fix: Fix rate limit retry body handling - #4658

Closed
sai5880 wants to merge 1 commit into
google:masterfrom
sai5880:fix/retry-body-4656
Closed

sai5880 wants to merge 1 commit into
google:masterfrom
sai5880:fix/retry-body-4656

Conversation

@sai5880

@sai5880 sai5880 commented Oct 21, 2026

Copy link
Copy Markdown
Contributor

Summary

Fix the primary rate-limit retry path so it replays the request body instead of
sending the already consumed body. If the request has a body that cannot be
replayed (GetBody is nil), the retry is skipped and the rate limit error is
returned.

Changes

  • Restore req.Body from req.GetBody() before retrying in bareDo.
  • Do not retry body-carrying requests when GetBody is nil.
  • Add POST, PUT, and PATCH tests that verify the retried request receives the
    full JSON body, plus a test for the non-replayable body case.

Tests

  • go test ./github/ -run "RateLimit|Retry" -count=1
  • go test ./github/ -count=1
  • go test ./... -count=1 in the otel module

AI assistance: drafted with an AI coding agent and reviewed before submission.

Fixes #4656

@gmlewis gmlewis changed the title Fix rate limit retry body handling fix: Fix rate limit retry body handling Oct 21, 2026
@gmlewis

gmlewis commented Oct 21, 2026

Copy link
Copy Markdown
Collaborator

This looks like a duplicate of #4657, right?

@codecov

codecov Bot commented Oct 21, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 85.71429% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 98.62%. Comparing base (2190e6a) to head (53cba7a).

Files with missing lines Patch % Lines
github/github.go 85.71% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #4658      +/-   ##
==========================================
- Coverage   98.63%   98.62%   -0.01%     
==========================================
  Files         201      201              
  Lines       18867    18874       +7     
==========================================
+ Hits        18609    18615       +6     
- Misses        258      259       +1     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@sai5880

sai5880 commented Oct 21, 2026

Copy link
Copy Markdown
Contributor Author

You are right, #4657 covers this. Closing this PR as a duplicate.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Rate-limit retry replays a consumed request body for POST/PUT/PATCH

2 participants