Skip to content

feat: Add LastRequestExecuting event for resumable uploads - #2

Open
mahendra-google wants to merge 2 commits into
mainfrom
feat/upload-last-request-event
Open

feat: Add LastRequestExecuting event for resumable uploads#2
mahendra-google wants to merge 2 commits into
mainfrom
feat/upload-last-request-event

Conversation

@mahendra-google

@mahendra-google mahendra-google commented Jun 8, 2026

Copy link
Copy Markdown
Owner

This PR introduces the LastRequestExecuting event to the ResumableUpload class , providing capability to modify the HttpRequestMessage right before the final upload chunk is uploaded to the server.

This capability is essential for client libraries (such as Google.Cloud.Storage.V1) that need to attach server-side validation headers (e.g., x-goog-hash: crc32c=...) on the final chunk of a resumable upload.

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces a new LastRequestExecuting event to the ResumableUpload class, which is triggered when the final chunk of data is uploading. It also adds corresponding unit tests to verify the event's behavior in both single-chunk and multi-chunk upload scenarios. The review feedback suggests correcting a minor grammatical typo in the event's XML documentation and splitting two statements onto separate lines in the multi-chunk test file to improve readability.

Important

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.

Comment on lines +209 to +211
/// <summary>
/// Event called when the final chunk of a data is uploading.
/// </summary>

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

There is a minor grammatical typo in the XML documentation: 'final chunk of a data' should be 'final chunk of data' or 'final chunk of the data'.

        /// <summary>
        /// Event called when the final chunk of data is uploading.
        /// </summary>

using (var service = new MockClientService(server.HttpPrefix))
{
var content = knownSize ? new MemoryStream(UploadTestBytes) : new UnknownSizeMemoryStream(UploadTestBytes);
var uploader = new TestResumableUpload(service, "MultiChunk", "POST", content, "text/plain", chunkSize); int eventInvokeCount = 0;

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

For better readability and adherence to standard C# coding conventions, avoid placing multiple statements on a single line. Please split the uploader initialization and the eventInvokeCount declaration into separate lines.

                var uploader = new TestResumableUpload(service, "MultiChunk", "POST", content, "text/plain", chunkSize);
                int eventInvokeCount = 0;

@mahendra-google

Copy link
Copy Markdown
Owner Author

/gemini review

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces a new LastRequestExecuting event to ResumableUpload, which fires when the final chunk of data is being uploaded. It also adds comprehensive unit tests to verify this event's behavior across single-chunk, multi-chunk, HTTP retry, and protocol retry scenarios. The feedback suggests a minor improvement in one of the new tests to replace an unnecessary single-iteration loop with a direct assertion, which will improve code readability.

Important

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.

Comment on lines +191 to +194
for (int i = 0; i < 1; i++)
{
Assert.Equal("MyToken", server.ReceivedCustomHeaders[i]);
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The for loop here is configured to run for exactly one iteration (i < 1), which is unnecessary and reduces code readability. It is cleaner and more direct to assert on the first element of server.ReceivedCustomHeaders directly without a loop.

                Assert.Equal("MyToken", server.ReceivedCustomHeaders[0]);

@mahendra-google

Copy link
Copy Markdown
Owner Author

/gemini review

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces a new LastRequestExecuting event to the ResumableUpload class, which is triggered when the final chunk of data is being uploaded. It also includes comprehensive unit tests for both single-chunk and multi-chunk uploads, verifying that the event fires correctly and that custom headers are preserved during HTTP and protocol retries. There are no review comments, and I have no additional feedback to provide.

Important

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.

@mahendra-google
mahendra-google force-pushed the feat/upload-last-request-event branch from 188637f to ff35b35 Compare July 17, 2026 09:11
@mahendra-google mahendra-google changed the title feat: Add LastRequestExecuting event in resumable upload feat: Add LastRequestExecuting event for resumable uploads Jul 17, 2026
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.

1 participant