Closed mttkay closed 3 years ago
Looking at https://cloud.google.com/storage/docs/json_api/v1/objects/get#response, I noticed this paragraph:
By default, this responds with an object resource in the response body. If you provide the URL parameter alt=media, then it will respond with the object data in the response body.
And in the request URL, we indeed send ?alt=media
(twice for some reason.)
So GCS will send back a binary file, and it looks like we then try to parse this as JSON?
I verified this isn't happening in fog-google
1.13. Here is how that request looks like:
D, [2021-06-23T13:50:13.269963 #1476] DEBUG -- : Sending HTTP get https://storage.googleapis.com/storage/v1/b/mk-omnibus-upload-test/o/lost_and_found%2F79%2F02%2F7902699be42c8a8e46fbbb4501726517e86b22c56a189f7625a6da49081b2451%2Fpackages%2F1%2Ffiles%2F1%2Fmy-app-1.0.jar?
D, [2021-06-23T13:50:13.323003 #1476] DEBUG -- : 200
It looks like request logs look completely different, not sure why.
I just noticed that in 1.14 the copy_object
implementation has changed w.r.t. option handling: https://github.com/fog/fog-google/pull/520/files
I wonder if it's related.
I wonder if it's related.
Maybe not related. I tested with those changes reverted and the problem persists.
@mttkay Could you try reverting e83c58efa1c7031ad82997607d739b672b9b3be1? I wonder if we just need to open Tempfile
with binmode: true
.
Ok, I reproduced the problem. Indeed, we need to call buf.binmode
to activate the binary stream.
https://github.com/fog/fog-google/pull/534 solves this issue.
534 solves this issue.
Yes I can confirm this fixes the issue. Thanks @stanhu !
Fix released in v1.15.0.
Fix released in v1.15.0.
Thank you @geemus ! :bow:
Broken out of this discussion: https://github.com/fog/fog-google/pull/530/files#r645936386
With
fog-google
1.14.0 we are seeing the following error when using theFile.copy
method and the target object is a binary file (in this case, a Java JAR file):Apparently somewhere in the communication between
client -> fog-google/json-storage -> google-api-ruby-client -> GCS
there is a problem with how byte streams are interpreted.Possibly related problem: googleapis/google-api-ruby-client#74
I believe what is happening here is that somewhere, that binary byte stream is being interpreted as a UTF-8 string, which it is not:
Note how there are multiple sequences containing c4XX multi-byte sequences, which denote certain characters with diacritics in Unicode: https://www.utf8-chartable.de/unicode-utf8-table.pl?start=256
Request logs of the failing request: