Skip to content

MD5 verification error when downloading a specific file generation #3733

@ozziek

Description

@ozziek

Environment details

  • OS: MacOS
  • Ruby version: ruby 2.5.5p157 (2019-03-15 revision 67260) [x86_64-darwin18]
  • Gem name and version: google-cloud-storage (1.19.0)

Steps to reproduce

  • Enable bucket versioning
  • Upload a .json file
  • Get the generation number for it
  • Upload a new .json which replaces the previous file
  • Attempt to download the previous file

Code example

data = JSON.pretty_generate({ "name" => "Roger" })
# => "{\n  \"name\": \"Roger\"\n}"

# generate brand new file
bucket.create_file(StringIO.new(data), "test_1.json")
=> #<Google::Cloud::Storage::File: ... >

prev_generation = bucket.file("test_1.json").generation
# => 1564749365636895

# update the data with different infromation
data = JSON.pretty_generate({ "name" => "Ozzie" })
# => "{\n  \"name\": \"Ozzie\"\n}"

# upload to the same location, forcing a new version
bucket.create_file(StringIO.new(data), "test_1.json")
# => #<Google::Cloud::Storage::File: ... >

# parsing from the current file works fine
current_file = bucket.file("test_1.json").download
JSON.parse(current_file.read) 
# => {"name"=>"Ozzie"}

# parsing the previous file does not
prev_file = bucket.file("test_1.json", generation: prev_generation).download

# Google::Cloud::Storage::FileVerificationError: The downloaded file failed MD5 verification.
# from ruby/2.5.5/gems/google-cloud-storage-1.19.0/lib/google/cloud/storage/file/verifier.rb:34:in `verify_md5!'

Full backtrace

Google::Cloud::Storage::FileVerificationError: The downloaded file failed MD5 verification.
from /Users/ozziekirkbu/.gem/ruby/2.5.5/gems/google-cloud-storage-1.19.0/lib/google/cloud/storage/file/verifier.rb:34:in `verify_md5!'

Notes

  • Copying the older generation file from gsutil works fine.
  • Might be related to the download method. It doesn't seem to include the generation number when downloading the file.

Metadata

Metadata

Assignees

Labels

api: storageIssues related to the Cloud Storage API.priority: p2Moderately-important priority. Fix may not be included in next release.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