Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mismatched checksums on a couple gems #1551

Closed
tjgrathwell opened this issue Jan 24, 2017 · 19 comments
Closed

Mismatched checksums on a couple gems #1551

tjgrathwell opened this issue Jan 24, 2017 · 19 comments
Labels

Comments

@tjgrathwell
Copy link

From rubygems/bundler#5332

Since Bundler 1.14 started validating checksums, a couple of people have had failed builds caused by seemingly invalid checksums in the RubyGems DB.

gem rubygems says shasum says
faraday_middleware c56bb3661af1d5057e578d72d2f9e93ab52630b74ebe37ce1118c93a6ddff56b ff2bdbb6bdd5b2293f8ce7cb93572318dd068506e12f987f04a65209a2bc69cb
azure-core b04f7f994e3abc31003139a7ff8a682980c1d064a906a3290d5c369685bc478b 68ebac6994412a775584478961747a215d0844737a8b9a91405a0ac77fe6c514

@chrismo ran a check on the 700 most popular gems and didn't find any other instances, but that doesn't mean they aren't out there! It would be nice to know how these SHAs ended up this way.

@cpetschnig
Copy link

hash_kit 0.4.8 is also affected: The expected SHA256 checksum was
"f7ae2829a96761a0569eac8f20066038c6ace083b797465d19e2a6f03aa3af94", but the
checksum for the downloaded gem was
"e4c66f4c62f66946de11fbbd9839b8cce78f89661977ae03b551e446dc729c8e".

@sonalkr132
Copy link
Member

I tried pushing faraday_middleware-0.11.0.gem and hash_kit-0.4.8.gem on my development instance, it generated the expected sha256 values, ie ff2bdbb6bdd5b2293f8ce7cb93572318dd068506e12f987f04a65209a2bc69cb and e4c66f4c62f66946de11fbbd9839b8cce78f89661977ae03b551e446dc729c8e.

I am afraid it is going to be difficult to solve unless we can reproduce the issue.

@sonalkr132 sonalkr132 added the bug label Jan 24, 2017
@sonalkr132
Copy link
Member

Can someone please send me the original .gem file, the one which was generated using gem build ..?

cc: @iMacTia

@iMacTia
Copy link
Contributor

iMacTia commented Jan 24, 2017

Hi @sonalkr132 we have an automated process in Faraday and FaradayMiddleware that bundle and push the gem automatically from Travis. That's because I'm not the main maintainer of the gems and I don't have writing permissions on rubygems.

I think @mislav will be able to help in this case.

@iMacTia
Copy link
Contributor

iMacTia commented Jan 24, 2017

I'm not sure that will help, but the bugged checksum was generated from this tag https://github.com/lostisland/faraday_middleware/tree/v0.11.0

@sonalkr132
Copy link
Member

I'm not sure that will help, but the bugged checksum was generated from this tag

Yeah, I already tried that. It generates a completely different checksum.

@iMacTia
Copy link
Contributor

iMacTia commented Jan 24, 2017

@navidemad I think that's not needed anymore as I released v0.11.0.1 yesterday
It's a carbon-copy of v0.11.0, but this time the correct checksum was generated

@sarangan12
Copy link

For the problem with the checksum of azure-core (and similar gems), should we release a new version? Is that the only solution?

Also, how could we be sure that re-releasing the gem will generate the correct checksum?

@007
Copy link

007 commented Jan 30, 2017

Unrelated to Faraday or azure-core, https://rubygems.org/gems/csvlint/versions/0.1.2 is failing validation.

RubyGems: 6af618357fdc57e8b87750742338032f9df8692d0f8f756436c6828383fd0f37
Actual: 24566781f6be914d26b8a31da50f8a6e1eb5d5026419923485e59351f6a84bc0

@sonalkr132
Copy link
Member

I pushed some 15 versions to our staging site and all of them generated correct checksum.
Regretfully, pushing a new version seems to the only option here unless someone can up with a .gem file which generates an incorrect sha value.

@dwradcliffe
Copy link
Member

I think most of these are older versions, probably from before we saved the checksums on gem push. I'm guessing there were a few that didn't get backfilled properly. Unless someone has an example of a recent (and repeatable) missmatch I don't think we have an ongoing problem here.

For these old ones, I think it's probably best to release new versions than go back and mess with the old versions.

@indirect
Copy link
Member

I agree... we can correct the checksums in the database, but it's much safer to do them all at once. Then we also only have to expire the versions list and force everyone to download the whole thing again one time.

For the time being, please release new versions to force correct checksums, and we'll go back and fix the checksums on old versions all at once.

@arthurnn
Copy link
Member

funny thing tho. I, THINK(not 100% sure), that when I ran the jobs the generate the checksums, I had something to double check them.

@segiddins
Copy link
Member

Fixing the checksums wont expire the versions list, only the respective info files

@mwpastore
Copy link

mailgun-ruby-1.1.3 also seems to be affected.

@tiagoamaro
Copy link

Just bumped into this issue when downloading faraday 0.12.0 (using latest rubygems version: 2.6.11). I've tried the following approach:

For faraday 0.12.0:

  • gem fetch faraday -v 0.12.0
  • shasum -a256 faraday-0.12.0.gem
    • Resulted in the following hash: 974ec50064433c84a0015b9f985d676e82b5532fd82ca0e2e546fbd63034a1b8 faraday-0.12.0.gem
    • Rubygems hash: 467b18cc2683845e90996e2c7f3af0cf34493d78b687445b2b4999711f6f6dca

For Faraday 0.11.0:

  • gem fetch faraday -v 0.11.0
  • shasum -a256 faraday-0.11.0.gem
    • Resulted in the following hash: 5986f49009d638d971997082f1a6cf1ed835144a66d5c11dd495bf1d9b66e1a2 faraday-0.11.0.gem
    • Rubygems hash: 5986f49009d638d971997082f1a6cf1ed835144a66d5c11dd495bf1d9b66e1a2

@iMacTia
Copy link
Contributor

iMacTia commented Apr 1, 2017

Thanks for reporting this @tiagoamaro, I released version 0.12.0 this morning and it had the same issue we had with faraday_middleware.
Last time I solved releasing again, @sonalkr132 do you need time to investigate or can I proceed releasing again?

@sonalkr132
Copy link
Member

sonalkr132 commented Apr 1, 2017

do you need time to investigate or can I proceed releasing again?

I believe we know why this is happening. You are using Travis to push gems. Travis ends pushing the gem from all the jobs. One of them pass and rest fail. Because of the race condition in Api::V1::RubygemsController#create, we end up with incorrect checksums.
You are welcome to leave your thoughts about proposed fix on #1564.

For the time being, you can use condition: "$TRAVIS_RUBY_VERSION == x.x.x" in your .travis.yml file to ensure that you don't end up pushing same version multiple times.

domcleal added a commit to domcleal/faraday that referenced this issue Apr 1, 2017
Restrict gem publishing to the Ruby 2.4.0 + SSL matrix job.

Per rubygems/rubygems.org#1551 (comment)
iMacTia pushed a commit to lostisland/faraday that referenced this issue Apr 2, 2017
Restrict gem publishing to the Ruby 2.4.0 + SSL matrix job.

Per rubygems/rubygems.org#1551 (comment)
@iMacTia
Copy link
Contributor

iMacTia commented Apr 2, 2017

Thanks for your input @sonalkr132.
The condition have been added and I'm re-publishing the gem, hopefully this time will be ok.

cimnine added a commit to ninech/netbox-client-ruby that referenced this issue Apr 16, 2018
rohitpaulk added a commit to segmentio/analytics-ruby that referenced this issue May 1, 2018
Earlier, all our Travis build jobs (one for each ruby version) used to
attempt to push a tagged version to Rubygems. The idea here was that one
of these would succeed and all the other would fail saying 'repushing
versions isn't allowed'.

Turns out, there's a race condition in Rubygems in the controller we're
hitting. Details: rubygems/rubygems.org#1551

This commits instructs Travis to deploy only on a single build, so that
we're very unlikely to trigger said race condition.
bundlerbot added a commit that referenced this issue Jun 25, 2018
Persist records before uploading to s3

When same gem version is pushed in parallel, upload to s3 is run for both the process. Process which commits transaction in Rubygems#update_attributes_from_gem_specification! first gets to set version.sha256, while process which uploads to s3 last gets to write gem file. These two processes need not be same and hence lead of sha mismatch.
If we persist version record before uploading to s3, other processes will get record not unique violation and not overwrite gem file in s3.

[Failing test on master](https://travis-ci.org/sonalkr132/rubygems.org/jobs/376936366#L1309).
Fixes #1564
Fixes #1551
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet