Sitelet https://github.com/googleapis/google-cloud-java/issues/720
Skip to content

storage: "Failed to parse Content-Range header" when chunk-size upload is used #720

Description

@sudison

Here is the log:

Caused by: com.google.gcloud.storage.StorageException: 400 Bad Request
Failed to parse Content-Range header.
at com.google.gcloud.spi.DefaultStorageRpc.translate(DefaultStorageRpc.java:94)
at com.google.gcloud.spi.DefaultStorageRpc.write(DefaultStorageRpc.java:499)
at com.google.gcloud.storage.BlobWriteChannel$1.run(BlobWriteChannel.java:49)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
at com.google.gcloud.RetryHelper.doRetry(RetryHelper.java:181)
at com.google.gcloud.RetryHelper.runWithRetries(RetryHelper.java:247)
at com.google.gcloud.RetryHelper.runWithRetries(RetryHelper.java:237)
at com.google.gcloud.storage.BlobWriteChannel.flushBuffer(BlobWriteChannel.java:46)
at com.google.gcloud.BaseWriteChannel.close(BaseWriteChannel.java:147)

If I uploaded a file with size is exactly 2 x 1024 x 1024, and 1024 x 1024 as the chunk size, then I'll get above exception. However, if I changed the file size to 2 x 1024 x 1024 + 1, then the problem will go away.

Apparently, there is a bug in BlobWriteChannel->flushbuffer, if there is no data available, then there is no need to call options().rpc().write.

Activity

  1. mziccard commented on Mar 7, 2016

    @mziccard
    Contributor

    Hi @sudison thanks for the report. I managed to reproduce you issue, I will look into this and provide a fix as soon as possible.

  2. added
    type: bugError or flaw in code with unintended results or allowing sub-optimal usage patterns.
    api: storageIssues related to the Cloud Storage API.
    on Mar 7, 2016
  3. jean-philippe-martin commented on Mar 7, 2016

    @jean-philippe-martin

    PR #714 has a potential fix for that, making a note to try the repro after that request is merged.

  4. sudison commented on Mar 7, 2016

    @sudison
    Author

    I tried the fix in jean-philippe-martin@73b9ef6, I got

    com.google.api.client.http.HttpResponseException: 400 Bad Request
    {
    "error": {
    "errors": [
    {
    "domain": "global",
    "reason": "badRequest",
    "message": "Invalid Upload Request"
    }
    ],
    "code": 400,
    "message": "Invalid Upload Request"
    }
    }

    if length is zero, sending a upload request to cloud storage, will get above exception.

  5. aozarov commented on Mar 7, 2016

    @aozarov
    Contributor

    Yes, @sudison thank you. We realized that but unfortunately only added a comment in the PR and not here. We are waiting to see if there is a good way to fix that other than applying a workaround to fix it.

  6. sudison commented on Mar 7, 2016

    @sudison
    Author

    My fix for this issue is to add a method:
    void totalLength(long length);
    on WriteChannel.
    The assumption is that, caller knows the length of the file before uploading to GCS.

  7. aozarov commented on Mar 7, 2016

    @aozarov
    Contributor

    Indeed that is a way, but I don't think we should make knowing the total lengths a requirement (and GCS should be able to support it). There are various cases where one would not know the length and we would like to support them to.

  8. jean-philippe-martin commented on Mar 7, 2016

    @jean-philippe-martin

    Agreed. Having to specify the length would make Java NIO integration really hard as NIO users don't give the length before starting their writes via e.g. newOutputStream.

  9. sudison commented on Mar 7, 2016

    @sudison
    Author

    As a user, if I want to use this library now, what should I do? This is the basic requirement for a library which can upload/download a file.

  10. aozarov commented on Mar 7, 2016

    @aozarov
    Contributor

    We will fix it soon. How big is your Blob? Can you apply one of the create methods that takes the blob content in the meantime?

  11. sudison commented on Mar 7, 2016

    @sudison
    Author

    Ok, thanks. Blob is around 1 - 20 MB. Is create method ok for such blob?

  12. aozarov commented on Mar 7, 2016

    @aozarov
    Contributor

    20MB is on the bigger side but Yes, and you can use the create that accepts InputStream if you don't have the content in memory.

  13. sudison commented on Mar 7, 2016

    @sudison
    Author

    ok, thanks. then I'll use create for now.

  14. 19 remaining items

  15. added a commit that references this issue on Oct 6, 2022
  16. added a commit that references this issue on Feb 1, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

api: storageIssues related to the Cloud Storage API.type: bugError or flaw in code with unintended results or allowing sub-optimal usage patterns.

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions