GeezerVison is showing github.com — The downloaded data did not match the data from the server · Issue #654 · googleapis/google-cloud-node
The downloaded data did not match the data from the server #654DescriptionHey,
Any files that I get from the bucket "pubsite_prod_rev_", gets error code: CONTENT_DOWNLOAD_MISMATCH.
bucket.file("reviews/reviews_com.sample.android_201409.csv").download({
destination: './reviews.cvs'
},
function(err, content){
console.log(err.code);//CONTENT_DOWNLOAD_MISMATCH
});Activitybeshkenadze commented on Jul 18, 2015 jgeewax commented on Jul 18, 2015 stephenplusplus commented on Jul 19, 2015 @beshkenadze sorry that it's taken so long to get on this. It's hard to say what could be causing this or if it's related to #651.
The error is being returned because either an MD5 or CRC32c validation check isn't passing. In other words, the data you've received isn't matching the data that's stored in the bucket. You can workaround this by disabling validation:
bucket.file("reviews/reviews_com.sample.android_201409.csv").download({
destination: './reviews.cvs',
validation: false
},
function(err, content){
// No more mismatch error (hopefully)
});
If you want to do some debugging, I put up a branch you can swap out your gcloud dependency for. It will just do a little console.log-ing to help see what's going on:
$ npm install --save stephenplusplus/gcloud-node#spp--654 Reacted by Ilya Radchenko, DavidQueruel, Daniel Lewis BSc (Hons) and Sondre Sørbye Reacted by Arnas, Daniel Lewis BSc (Hons), Dev.Tutd and Ivan Coene beshkenadze commented on Jul 20, 2015 Hey @stephenplusplus,
How is getting of the hash from a local file?
Play Сloud gives files compressed in GZ format.
Possible hashes are calculated from the extracted file? jgeewax commented on Jul 20, 2015 Not sure I understand the question @beshkenadze ...
To give some background (sorry if you already know this, just adding for context):
I don't see anything that would indicate that we're looking at the uncompressed file, as we're treating the data as nothing more than bytes and ignoring the file type all together.
It could be possible that Play (when uploading the data) is somehow bypassing the part where they set the CRC32 and MD5 hash for the file (which would cause this error to happen on all Play-uploaded files). Could you tell us what you get back in the headers that start with x-goog-hash when you GET the files from GCS?
/cc @stephenplusplus beshkenadze commented on Jul 20, 2015 Now find the real file and will try to show an example. stephenplusplus commented on Jul 20, 2015
Could you tell us what you get back in the headers that start with x-goog-hash when you GET the files from GCS?
That's what this will do:
$ npm install --save stephenplusplus/gcloud-node#spp--654 beshkenadze commented on Jul 20, 2015 stephenplusplus commented on Jul 20, 2015 beshkenadze commented on Jul 20, 2015 I used request-debug and got this:
{
response: {
debugId: 1,
headers: {
'x-guploader-uploadid': 'XXXX',
expires: 'Mon, 20 Jul 2015 13:40:35 GMT',
date: 'Mon, 20 Jul 2015 13:40:35 GMT',
'cache-control': 'private, max-age=0',
'last-modified': 'Sun, 19 Jul 2015 18:53:59 GMT',
etag: 'W/"XXXX"',
'x-goog-generation': '1437332039288000',
'x-goog-metageneration': '1',
'x-goog-stored-content-encoding': 'gzip',
'x-goog-stored-content-length': '5939',
'content-type': 'text/csv; charset=utf-16le',
'x-goog-hash': 'crc32c=66rJzQ==, md5=2T/NKanU9vTItoiF7+tMAA==',
'x-goog-storage-class': 'STANDARD',
vary: 'Accept-Encoding',
'content-length': '24148',
server: 'UploadServer',
'alternate-protocol': '443:quic,p=1',
connection: 'close'
},
statusCode: 200
}
}stephenplusplus commented on Jul 20, 2015 Nice :) Using my branch will show the hashes that are being built locally as well. beshkenadze commented on Jul 20, 2015 @stephenplusplus ;)
Headers: { 'x-guploader-uploadid': 'XXXX',
expires: 'Mon, 20 Jul 2015 13:46:35 GMT',
date: 'Mon, 20 Jul 2015 13:46:35 GMT',
'cache-control': 'private, max-age=0',
'last-modified': 'Sun, 19 Jul 2015 18:53:59 GMT',
etag: 'W/"XXXX"',
'x-goog-generation': '1437332039288000',
'x-goog-metageneration': '1',
'x-goog-stored-content-encoding': 'gzip',
'x-goog-stored-content-length': '5939',
'content-type': 'text/csv; charset=utf-16le',
'x-goog-hash': 'crc32c=66rJzQ==, md5=2T/NKanU9vTItoiF7+tMAA==',
'x-goog-storage-class': 'STANDARD',
vary: 'Accept-Encoding',
'content-length': '24148',
server: 'UploadServer',
'alternate-protocol': '443:quic,p=1',
connection: 'close' }
Local CRC32c Hash: Fw==
Local MD5 Hash: Hwt6cw9joXTy4EOtQqh0pg==
crypto.js:126
return this._handle.digest(outputEncoding);
^
Error: Not initialized
at Error (native)stephenplusplus commented on Jul 20, 2015 Those don't match even a little bit! Like you pointed out @beshkenadze, I think we're running into issues because request automatically decodes the file as it's being downloaded, resulting in different hashes. I can't think of a great solution immediately for how we can work around this, other than:
- shut off the auto-decoding for all downloads (don't think we want this),
- ignore the hash mismatch if we see the file was gzip'd in the response headers,
- branch off from the
request download stream, and run the calculation on the native http.IncomingMessage response stream (which won't do the decoding)
jgeewax commented on Jul 20, 2015 Can we run a quick test of uploading a zipped file, and seeing that the
verification fails ? I'd feel much more confident if this was happening on
a non-magic bucket (the one in question here is actually owned by Google
Play, so it might be doing something wonky).
MetadataMetadataDevelopmentNo branches or pull requestsIssue actions
|