Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Add an exception to zero byte uploads on CreateFrom #2342

Merged
merged 2 commits into from
Jan 2, 2024

Conversation

JesseLovelace
Copy link
Contributor

@JesseLovelace JesseLovelace commented Dec 28, 2023

This PR introduced a bug in using createFrom to upload a zero byte object. I can't figure out where exactly the bug is, but something is causing the content range to be 0-1 instead of 0-0 in this case. It ends up getting rejected because the range is bigger than the content size, which is still zero.

We can fix the bug later when we identify the root cause, but for now I'm just reverting to the old way of doing it when we detect that we're uploading a zero byte file.

I also added a test for this case

@JesseLovelace JesseLovelace requested a review from a team as a code owner December 28, 2023 00:27
@product-auto-label product-auto-label bot added size: s Pull request size is small. api: storage Issues related to the googleapis/java-storage API. labels Dec 28, 2023
@BenWhitehead
Copy link
Collaborator

Fix looks well to me. In fact skipping creating a resumable session at all is a good call when the object is empty.

My guess is the error is actually a Content-Range header value of 0--1/0 (zero to -1 of zero). Which is calculated based on the 0 being passed in for size here

HttpContentRange contentRange =
HttpContentRange.of(ByteRangeSpec.relativeLength(0L, size), size);

Thanks for the fix @JesseLovelace

@JesseLovelace JesseLovelace merged commit 2b5b27e into main Jan 2, 2024
21 checks passed
@JesseLovelace JesseLovelace deleted the fixzerobyte branch January 2, 2024 18:18
JesseLovelace added a commit that referenced this pull request Jan 22, 2024
* fix: Add an exception to zero byte uploads on CreateFrom

* 🦉 Updates from OwlBot post-processor

See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md

---------

Co-authored-by: Owl Bot <gcf-owl-bot[bot]@users.noreply.github.com>
JesseLovelace added a commit that referenced this pull request Jan 22, 2024
* fix: Add an exception to zero byte uploads on CreateFrom

* 🦉 Updates from OwlBot post-processor

See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md

---------

Co-authored-by: Owl Bot <gcf-owl-bot[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api: storage Issues related to the googleapis/java-storage API. size: s Pull request size is small.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants