mirror of
https://github.com/fsouza/fake-gcs-server.git
synced 2026-04-25 21:55:56 +03:00
[GH-ISSUE #217] gsutil cp bad request #40
Labels
No labels
bug
compatibility-issue
docker
documentation
enhancement
help wanted
needs information
pull-request
question
stale
unfortunate
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
starred/fake-gcs-server#40
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @jonasfugedi on GitHub (Apr 19, 2020).
Original GitHub issue: https://github.com/fsouza/fake-gcs-server/issues/217
I need to test some bash scripts which run gsutil but I keep getting errors when trying to create objects using gsutil. The scenario I run is basically:
docker run --name fake-gcs-server -p 4443:4443 fsouza/fake-gcs-server
gsutil -o "Credentials:gs_json_host=0.0.0.0" -o "Credentials:gs_json_port=4443" -o "Boto:https_validate_certificates=False" mb "gs://test"
gsutil -o "Credentials:gs_json_host=0.0.0.0" -o "Credentials:gs_json_port=4443" -o "Boto:https_validate_certificates=False" ls "gs://test"
echo "Hello" | gsutil -o "Credentials:gs_json_host=0.0.0.0" -o "Credentials:gs_json_port=4443" -o "Boto:https_validate_certificates=False" cp - "gs://test/hello.txt"
Copying from ...
ResumableUploadStartOverException: 404 Bad Request
gsutil -o "Credentials:gs_json_host=0.0.0.0" -o "Credentials:gs_json_port=4443" -o "Boto:https_validate_certificates=False" cp ./tmp/funny-memes-81.jpg "gs://test/"
Copying file://./tmp/funny-memes-81.jpg [Content-Type=image/jpeg]...
BadRequestException: 400 Bad Request
@fsouza commented on GitHub (Apr 20, 2020):
Hey @jonasfugedi, thanks for opening this issue. What do you see in the server logs?
@jonasfugedi commented on GitHub (Apr 21, 2020):
The logs did not give me any good clues. Is there any debug flag I can enable to get more details?
time="2020-04-19T17:01:22Z"`
level=info
msg="172.17.0.1 - - [19/Apr/2020:17:01:22 +0000] "POST /resumable/upload/storage/v1/b/test/o?fields=generation%2CcustomerEncryption%2Cmd5Hash%2Ccrc32c%2Cetag%2Csize&alt=json&uploadType=resumable HTTP/1.1" 404 19"
server_log.txt
Also, I assume this is reproducible anywhere? I've only tried it on two machines so far.
@fsouza commented on GitHub (Apr 21, 2020):
@jonasfugedi thanks for sharing. I wanted to check where exactly the 400 was happening.
So:
uploadType=multipart, which fails with a 400. As far a I can tell, that endpoint fails when the Content-Type header can't be parsed as a multipart header, which may mean that whatever gsutil is sending isn't recognized by fake-gcs-server.I believe next step would be to try and tap into what gsutil is sending, creating a test and fixing the issue in fake-gcs-server. Will tag this as a bug.
Thanks again for reporting and for sharing the logs!
@ex-nerd commented on GitHub (Jun 3, 2020):
I think I'm running into this same issue in my tests to create signed upload URLs. When using fake-gcs server I just return a "direct" URL without the signing key (since that I can't fake KMS stuff and this works for downloads).
Edit: I'm not entirely sure this is the same bug, so I moved this comment over to #270 as its own thing.
@StephenWithPH commented on GitHub (Aug 25, 2020):
I'm having a similar problem with
gsutil cp. I did some digging. I think you are correct.gsutil -DD cp ...enables debugging. I was able to capture the headers. In my case, they were:https://stackoverflow.com/questions/43527820/mime-parsemediatype-fails-on-multipart-boundary gave me enough of a clue to mess with
'->"(thanks, Python?), and that seems to fix it. See https://play.golang.org/p/TJ5qzwTzSOk.I made the change on a fork and verified I was able to get past this error. See
github.com/StephenWithPH/fake-gcs-server@87e3e3e4e1.However...
gsutil cp ...is now failing at a different point:This is at https://github.com/GoogleCloudPlatform/gsutil/blob/master/gslib/commands/cp.py#L1053. I'm working backwards, but it looks like
fake-gcs-serverdoesn't send back the size of the object in its response.Of note, the object uploads successfully (see logs):
And the object is actually there in
fake-gcs-server:@ekimekim commented on GitHub (May 26, 2023):
An update: It seems that the second half of @StephenWithPH 's comment has been fixed - fixing the multipart boundary bug is now sufficient for
gsutil cpto work, at least for the version I'm using.I've made a PR with the
'->"hack.