Open
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Goal
Fix HTTP request retry failures that occurred when upload requests needed to be retried. When retries were enabled (
--retries > 0), subsequent retry attempts would fail with the error:error sending request: Post "https://upload.bugsnag.com:443/ndk-symbol": http: ContentLength=1278529 with Body length 0This prevented users from successfully uploading symbol files when transient network issues or duplicate file conflicts occurred.
Design
The root cause was that HTTP request bodies (io.Reader) can only be read once. When a request failed and needed to be retried, the body stream had already been consumed by the first attempt, leaving an empty body for subsequent retries.
The fix implements the following approach:
bytes.Bufferwithbytes.NewReader, which can be recreated from the stored byteshttp.Request.GetBodyfield to provide a function that returns a fresh reader from the stored bytesGetBody()and assign the result torequest.Bodybefore each retry attemptThis approach allows the request body to be "rewound" and re-read for each retry attempt, which is the standard pattern for implementing retryable HTTP requests in Go.
Changeset
pkg/server/request.go:buildFileRequest(): Store multipart form body as bytes, usebytes.NewReader, and setGetBodycallbackProcessBuildRequest(): Store JSON payload bytes, usebytes.NewReader, and setGetBodycallbackprocessRequest(): Added explicit body reset logic before each retry by callingGetBody()and reassigning torequest.BodyTesting
Manual Testing:
./bin/arm64-macos-bugsnag-cli upload unity-android platforms-examples/Unity/UnityExample-1.0-v1-IL2CPP.symbols.zip --api-key=<key> --retries=3 --verbosemake buildAutomated Testing:
Covered by CI