Skip to content

Fix truncated Storage uploads after retrying the final chunk - #8614

Open
tyler-besimple wants to merge 2 commits into
firebase:mainfrom
tyler-besimple:fix/storage-final-chunk-truncation
Open

tyler-besimple wants to merge 2 commits into
firebase:mainfrom
tyler-besimple:fix/storage-final-chunk-truncation

Conversation

@tyler-besimple

Copy link
Copy Markdown

A failed final upload request can leave more than 256 KiB buffered after the input stream has reached EOF. uploadChunk() resets the retry size to 256 KiB, but uses EOF alone to decide whether to finalize the request and report success. The smaller retry can therefore finalize a truncated object while buffered bytes remain unsent.

Finalize only when the stream has reached EOF and the current request includes all remaining buffered bytes. Use that same condition when deciding whether to advance the buffer or complete the task.

Added two deterministic regression tests through putBytes() with mocked HTTP connections: a failed final request that stores no bytes, and one that stores 256 KiB before failing. The tests verify status recovery, upload offsets, complete byte-for-byte payloads, transferred-byte counts, and returned metadata sizes.

For the 1,310,843-byte test payload, the original code reports success after storing only 1,048,576 bytes or 1,310,720 bytes, respectively. Both tests pass with the fix.

Related to #6187. This reproduces a specific truncation mechanism; it does not establish that every report in that issue has the same cause.

Validation:

  • New regression tests: both fail on unchanged production code, then pass with the fix.
  • ./gradlew :firebase-storage:spotlessApply: passed.
  • ./gradlew :firebase-storage:check: passed (124 debug tests and 124 release tests, no failures or skips; lint and formatting checks passed).
  • git diff --check: passed.

Validation used Java 17, Android API 34, and the repository-supported subprojects.local.cfg subset for Storage and its build tooling. No public APIs or dependencies changed.

@gemini-code-assist

Copy link
Copy Markdown
Contributor
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize the Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counterproductive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here.

@google-cla

google-cla Bot commented Sep 18, 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.

@tyler-besimple
tyler-besimple marked this pull request as draft September 18, 2026 01:43
@tyler-besimple
tyler-besimple marked this pull request as ready for review September 18, 2026 01:43

This branch has not been deployed

No deployments
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