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

Downloading binaries of 4.6.1 fails with wrong sha256 checksum #16233

Closed
Trainxy opened this issue Nov 11, 2022 · 32 comments
Closed

Downloading binaries of 4.6.1 fails with wrong sha256 checksum #16233

Trainxy opened this issue Nov 11, 2022 · 32 comments
Labels
bug/2-confirmed Bug has been reproduced and confirmed. kind/bug A reported bug. team/client Issue for team Client. team/schema Issue for team Schema. topic: engine download
Milestone

Comments

@Trainxy
Copy link

Trainxy commented Nov 11, 2022

Bug description

npm ERR! code 1
npm ERR! path /home/d2766cb87e42ac78b6cf6400f1e52be457744eee/node/node_modules/@prisma/engines
npm ERR! command failed
npm ERR! command sh -c -- node scripts/postinstall.js
npm ERR! /home/d2766cb87e42ac78b6cf6400f1e52be457744eee/node/node_modules/@prisma/engines/dist/scripts/postinstall.js:22677
npm ERR!             throw new Error(`sha256 of ${url} (zipped) should be ${zippedSha256} but is ${zippedHash}`);
npm ERR!                   ^
npm ERR!
npm ERR! Error: sha256 of https://binaries.prisma.sh/all_commits/694eea289a8462c80264df36757e4fdc129b1b32/rhel-openssl-1.1.x/migration-engine.gz (zipped) should be b8137868e4dc45f6cb384173fbfc7606b4cb0641328720f2fad95c5e74e6971c but is fbd2f419c17eec8e962e07b8caf71653775c7d8e12db49029b691900513c2354

How to reproduce

$ wget https://binaries.prisma.sh/all_commits/694eea289a8462c80264df36757e4fdc129b1b32/rhel-openssl-1.1.x/migration-engine.gz
--2022-11-11 10:04:38--  https://binaries.prisma.sh/all_commits/694eea289a8462c80264df36757e4fdc129b1b32/rhel-openssl-1.1.x/migration-engine.gz
Resolving binaries.prisma.sh (binaries.prisma.sh)... 13.32.50.55, 13.32.50.41, 13.32.50.7, ...
Connecting to binaries.prisma.sh (binaries.prisma.sh)|13.32.50.55|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 13665486 (13M) [binary/octet-stream]
Saving to: 'migration-engine.gz'

migration-engine.gz                                        100%[========================================================================================================================================>]  13.03M  30.3KB/s    in 1m 46s

2022-11-11 10:06:25 (126 KB/s) - 'migration-engine.gz' saved [13665486/13665486]

$ sha256sum migration-engine.gz
fbd2f419c17eec8e962e07b8caf71653775c7d8e12db49029b691900513c2354  migration-engine.gz

Expected behavior

Correct sha256 checksum when downloading the binary.

Prisma information

Not needed, installation of prisma fails even without a schema.

Environment & setup

OS: CentOS 7.5
Database: MySQL
Node.js version: 18.12.1

Prisma Version

4.6.0
@Trainxy Trainxy added the kind/bug A reported bug. label Nov 11, 2022
@87brandonn
Copy link

got the same error here. did you find any solution to this? @Trainxy

@1Vlod
Copy link

1Vlod commented Nov 11, 2022

Got the same error with prisma 4.5.0 in docker on ubuntu

@1Vlod
Copy link

1Vlod commented Nov 11, 2022

Does anyony have a solution?

That's funny, because we have a demo today but now we cannot rebuild our containers

I thought it depends on prisma version, but it looks like it doesn't

@janpio
Copy link
Member

janpio commented Nov 11, 2022

Hey everyone who reported this @87brandonn @1Vlod @Trainxy, some things you can do to help us understand this:

  1. Are you trying to upgrade to 4.6.1 when this happens?
  2. Where are you or your server that is doing the downloading located?
  3. What operating system are you running and which binary type (rhel-openssl-1.1.x in the example above) is your Prisma CLI trying to download?
  4. Can you test with another internet connection, e.g. mobile tethering via mobile phone and see if the problem persists?
  5. If you have not, please include the full error message (as @Trainxy did, with the URLs and checksums and so on) in a comment here so we can really look deep at what is going on.
  6. Can you please upload the gz file that is causing the problem (by clicking the link in the error message) here in a comment so we can compare them to what should be returned?

Thanks.

@janpio
Copy link
Member

janpio commented Nov 11, 2022

Thanks for the information you included in your initial descriptoin @Trainxy. I get a different checksum after downloading:

janpio@Surface-Studio:~$ wget https://binaries.prisma.sh/all_commits/694eea289a8462c80264df36757e4fdc129b1b32/rhel-openssl-1.1.x/migration-engine.gz
--2022-11-11 10:04:54--  https://binaries.prisma.sh/all_commits/694eea289a8462c80264df36757e4fdc129b1b32/rhel-openssl-1.1.x/migration-engine.gz
Resolving binaries.prisma.sh (binaries.prisma.sh)... 99.84.146.16, 99.84.146.14, 99.84.146.111, ...
Connecting to binaries.prisma.sh (binaries.prisma.sh)|99.84.146.16|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 13665931 (13M) [binary/octet-stream]
Saving to: ‘migration-engine.gz’

migration-engine.gz         100%[===========================================>]  13.03M  27.2MB/s    in 0.5s

2022-11-11 10:04:55 (27.2 MB/s) - ‘migration-engine.gz’ saved [13665931/13665931]

janpio@Surface-Studio:~$ sha256sum migration-engine.gz
b8137868e4dc45f6cb384173fbfc7606b4cb0641328720f2fad95c5e74e6971c  migration-engine.gz

And that is indeed the one our tool expects, and talks about in the error message:

npm ERR! Error: sha256 of https://binaries.prisma.sh/all_commits/694eea289a8462c80264df36757e4fdc129b1b32/rhel-openssl-1.1.x/migration-engine.gz (zipped) should be b8137868e4dc45f6cb384173fbfc7606b4cb0641328720f2fad95c5e74e6971c but is fbd2f419c17eec8e962e07b8caf71653775c7d8e12db49029b691900513c2354

To confirm anyone can run these two commands:

wget https://binaries.prisma.sh/all_commits/694eea289a8462c80264df36757e4fdc129b1b32/rhel-openssl-1.1.x/migration-engine.gz
sha256sum migration-engine.gz

The returned string should be the b813786... one.

@janpio janpio added team/schema Issue for team Schema. team/client Issue for team Client. topic: engine download bug/0-unknown Bug is new, does not have information for reproduction or reproduction could not be confirmed. labels Nov 11, 2022
@dev-isemo
Copy link

Same error here. Im using Docker with a node:18-alpine Image

#8 34.42 npm ERR! code 1
#8 34.42 npm ERR! path /app/node_modules/@prisma/engines
#8 34.42 npm ERR! command failed
#8 34.42 npm ERR! command sh -c -- node scripts/postinstall.js
#8 34.42 npm ERR! /app/node_modules/@prisma/engines/dist/scripts/postinstall.js:22677
#8 34.42 npm ERR!             throw new Error(`sha256 of ${url} (zipped) should be ${zippedSha256} but is ${zippedHash}`);
#8 34.42 npm ERR!                   ^
#8 34.42 npm ERR!
#8 34.42 npm ERR! Error: sha256 of https://binaries.prisma.sh/all_commits/694eea289a8462c80264df36757e4fdc129b1b32/linux-musl/migration-engine.gz (zipped) should be fef9a669cb5a4a866b0c3f54c87b19fa23b34029770e156ff65af0086b8cfb47 but is a8c0f25dba718250a33974276a0dacbcc8e8d9ac754ef2f60c40fbc011b772fd
#8 34.42 npm ERR!     at /app/node_modules/@prisma/engines/dist/scripts/postinstall.js:22677:19
#8 34.42 npm ERR!     at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
#8 34.42 npm ERR!
#8 34.42 npm ERR! Node.js v18.12.1
  1. Fails for 4.5.0 / 4.6.1
  2. Located in Frankfurt Germany
  3. File: migration-engine.gz

@eliliam
Copy link

eliliam commented Nov 11, 2022

This is a huge issue that needs to be addressed, does anyone have a temporary band aid fix for this?

@janpio
Copy link
Member

janpio commented Nov 11, 2022

@dev-isemo:

#8 34.42 npm ERR! Error: sha256 of https://binaries.prisma.sh/all_commits/694eea289a8462c80264df36757e4fdc129b1b32/linux-musl/migration-engine.gz (zipped) should be fef9a669cb5a4a866b0c3f54c87b19fa23b34029770e156ff65af0086b8cfb47 but is a8c0f25dba718250a33974276a0dacbcc8e8d9ac754ef2f60c40fbc011b772fd

When I download that file and checksum it, I get the correct one:

janpio@Surface-Studio:~$ wget https://binaries.prisma.sh/all_commits/694eea289a8462c80264df36757e4fdc129b1b32/linux-musl/migration-engine.gz
--2022-11-11 19:58:21--  https://binaries.prisma.sh/all_commits/694eea289a8462c80264df36757e4fdc129b1b32/linux-musl/migration-engine.gz
Resolving binaries.prisma.sh (binaries.prisma.sh)... 99.84.146.14, 99.84.146.22, 99.84.146.111, ...
Connecting to binaries.prisma.sh (binaries.prisma.sh)|99.84.146.14|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 15090616 (14M) [binary/octet-stream]
Saving to: ‘migration-engine.gz.1’

migration-engine.gz.1       100%[===========================================>]  14.39M  27.5MB/s    in 0.5s

2022-11-11 19:58:22 (27.5 MB/s) - ‘migration-engine.gz.1’ saved [15090616/15090616]

janpio@Surface-Studio:~$ sha256sum migration-engine.gz.1
fef9a669cb5a4a866b0c3f54c87b19fa23b34029770e156ff65af0086b8cfb47  migration-engine.gz

@janpio
Copy link
Member

janpio commented Nov 11, 2022

@eliliam had posted in a separate issue:

While trying to install prisma via npm install prisma, the installation fails in the step where it installs @prisma/engines and tries to download the migration-engine.gz binary. When it compares the hash with what it's "supposed" to be, the comparison fails causing the whole installation to fail.

Screenshot 2022-11-11 at 11 09 08 AM

Here is the file that was downloaded for me, as well as the link in question. Link: binaries.prisma.sh/all_commits/694eea289a8462c80264df36757e4fdc129b1b32/debian-openssl-1.1.x/migration-engine.gz

My version: migration-engine.gz

@eliliam
Copy link

eliliam commented Nov 11, 2022

What would be causing different users to retrieve different files entirely when they should be the same?

@janpio
Copy link
Member

janpio commented Nov 11, 2022

CDN or network issues.

For now we have 3 reports from differnet people, but all with different operating systems: rhel-openssl-1.1.x from @Trainxy, linux-musl by @dev-isemo and debian-openssl-1.1.x by you @eliliam. When I download most of these, I get the same hashes that the CLI seems to expect.

@janpio
Copy link
Member

janpio commented Nov 11, 2022

So to list all the cases and error messages:

  1. Error: sha256 of https://binaries.prisma.sh/all_commits/694eea289a8462c80264df36757e4fdc129b1b32/rhel-openssl-1.1.x/migration-engine.gz (zipped) should be b8137868e4dc45f6cb384173fbfc7606b4cb0641328720f2fad95c5e74e6971c but is fbd2f419c17eec8e962e07b8caf71653775c7d8e12db49029b691900513c2354
  2. Error: sha256 of https://binaries.prisma.sh/all_commits/694eea289a8462c80264df36757e4fdc129b1b32/linux-musl/migration-engine.gz (zipped) should be fef9a669cb5a4a866b0c3f54c87b19fa23b34029770e156ff65af0086b8cfb47 but is a8c0f25dba718250a33974276a0dacbcc8e8d9ac754ef2f60c40fbc011b772fd
  3. Error: sha256 of https://binaries.prisma.sh/all_commits/694eea289a8462c80264df36757e4fdc129b1b32/debian-openssl-1.1.x/migration-engine.gz (unzipped) should be 003a64e669a41cbedc77eceddbcaa857e8e5d86a0f7e258dccc88cd3273b1c3 but is 6a14286c51fbc005ab193eac8dcca740275fd9716dd226e1f857fab2dc00d778

@janpio
Copy link
Member

janpio commented Nov 11, 2022

When collecting these, and trying to reproduce the hashes I noticed that your case @eliliam is actually different: The error message says (unzipped) instead of (zipped) for the others - which explains why the checksum for the downloaded .gz did not match either checksum value. When I unzipped the file, the checksum indeed was 6a14286c51fbc005ab193eac8dcca740275fd9716dd226e1f857fab2dc00d778 again as expected.

@janpio
Copy link
Member

janpio commented Nov 11, 2022

The remaining task for the previous comment that now would help a lot:

Can you test with another internet connection, e.g. mobile tethering via mobile phone and see if the problem persists?

@eliliam
Copy link

eliliam commented Nov 11, 2022

@janpio when I download it and decompress the gz file I still have a mismatched hash.

@janpio
Copy link
Member

janpio commented Nov 11, 2022

Can you upload the extracted file please and the checksum you get for that file? I think before you uploaded only the archive.

@eliliam
Copy link

eliliam commented Nov 11, 2022

SHA256 hash: 6a14286c51fbc005ab193eac8dcca740275fd9716dd226e1f857fab2dc00d778
Github won't let me upload the unzipped file due to file extension limits, so I've uploaded it elsewhere.
Here is the unzipped file: https://paste.c-net.org/EnhancePeaked
And here is the gzipped file before decompression: migration-engine.gz

As for trying a different internet connection, I have tried multiple different locations. It appears that I get this same hash on the file that was downloaded on my home and office networks, but I get the correct file when downloaded from my cell's 5G connection.

@janpio
Copy link
Member

janpio commented Nov 11, 2022

Something is off there @eliliam. When I use the gzipped file and unpack it, I get a different file than what you uploaded to paste.c-net.org - different size, content and (logically) checksum. Are you 100% sure that this comes from https://binaries.prisma.sh/all_commits/694eea289a8462c80264df36757e4fdc129b1b32/debian-openssl-1.1.x/migration-engine.gz?

@janpio
Copy link
Member

janpio commented Nov 11, 2022

Here is an archive with the original files from the CDN for debian-openssl-1.1.x, so https://binaries.prisma.sh/all_commits/694eea289a8462c80264df36757e4fdc129b1b32/debian-openssl-1.1.x/migration-engine.gz:
migration-engine.zip The archive, the checksum for the archive, and the checksum for the unpacked file.

@janpio
Copy link
Member

janpio commented Nov 11, 2022

Here is another case that was raised in an old issue:

    Since this morning we encounter this issue and there is not much information out there, so that is why I open this old issue :)

The Dockerfile executes RUN npm ci

[2022-11-11T14:28:23.999Z] Step 7/161 : RUN npm ci
[2022-11-11T14:28:23.999Z]  ---> Running in a3b499d60536
--- snip ---
[2022-11-11T14:29:06.387Z] npm ERR! code 1
[2022-11-11T14:29:06.387Z] npm ERR! path /app/node_modules/@prisma/engines
[2022-11-11T14:29:06.387Z] npm ERR! command failed
[2022-11-11T14:29:06.387Z] npm ERR! command sh -c -- node scripts/postinstall.js
[2022-11-11T14:29:06.387Z] npm ERR! /app/node_modules/@prisma/engines/dist/scripts/postinstall.js:22677
[2022-11-11T14:29:06.387Z] npm ERR!             throw new Error(`sha256 of ${url} (zipped) should be ${zippedSha256} but is ${zippedHash}`);
[2022-11-11T14:29:06.387Z] npm ERR!                   ^
[2022-11-11T14:29:06.387Z] npm ERR! 
[2022-11-11T14:29:06.387Z] npm ERR! Error: sha256 of https://binaries.prisma.sh/all_commits/694eea289a8462c80264df36757e4fdc129b1b32/linux-musl/migration-engine.gz (zipped) should be fef9a669cb5a4a866b0c3f54c87b19fa23b34029770e156ff65af0086b8cfb47 but is a8c0f25dba718250a33974276a0dacbcc8e8d9ac754ef2f60c40fbc011b772fd
[2022-11-11T14:29:06.387Z] npm ERR!     at /app/node_modules/@prisma/engines/dist/scripts/postinstall.js:22677:19
[2022-11-11T14:29:06.387Z] npm ERR!     at runMicrotasks (<anonymous>)
[2022-11-11T14:29:06.387Z] npm ERR!     at processTicksAndRejections (node:internal/process/task_queues:96:5)
[2022-11-11T14:29:06.387Z] 
[2022-11-11T14:29:06.387Z] npm ERR! A complete log of this run can be found in:
[2022-11-11T14:29:06.387Z] npm ERR!     /root/.npm/_logs/2022-11-11T14_28_24_565Z-debug-0.log
[2022-11-11T14:29:06.387Z] The command '/bin/sh -c npm ci' returned a non-zero code: 1

Is there a way to solve this on our own?

Originally posted by @DarkSmile92 in #10312 (comment)

@janpio
Copy link
Member

janpio commented Nov 11, 2022

@DarkSmile92 You case seems to be identical to #16233 (comment) :/

@janpio
Copy link
Member

janpio commented Nov 11, 2022

Our current thoughts:

  1. Either this is a hickup on AWS, S3 and Cloudfont that we can not influence
  2. Or this is another case of Invalidate CloudFront Cache when republishing engine files with same engine hash #10328 (comment) - but we have not find a clear indication for that.

@eliliam
Copy link

eliliam commented Nov 11, 2022

Here is an archive with the original files from the CDN for debian-openssl-1.1.x, so https://binaries.prisma.sh/all_commits/694eea289a8462c80264df36757e4fdc129b1b32/debian-openssl-1.1.x/migration-engine.gz: migration-engine.zip The archive, the checksum for the archive, and the checksum for the unpacked file.

I have redownloaded the file and created a similar zip of the gzipped file, extracted file, and their respective sha256 sums. I still get the same bad values.
migration-engine-bad.zip

If it is indeed a CloudFront caching issue, what steps need to be taken to resolve this issue, and who is able to accomplish this?

@janpio
Copy link
Member

janpio commented Nov 11, 2022

That would be us of course.

I just triggered a minimal invalidation. Can you check if the problem is already resolved maybe?

(The problem here is always that only some CDN nodes are affected, and it seems this time I have no way to reproduce this at all)

@asciant
Copy link

asciant commented Nov 11, 2022

I was receiving the error message, found this issue and @janpio can confirm that after your comment I was able to run npm install without issue.

@DarkSmile92
Copy link

Works for me again! 👍

@eliliam
Copy link

eliliam commented Nov 11, 2022

@janpio Fantastic that worked for me too!

@janpio
Copy link
Member

janpio commented Nov 11, 2022

Thanks. Sorry that took so long to connect the dots, only the second time in the last 3 years this happened.

I'll wait for confirmation from @Trainxy to close the issue, or they can do that themselves.

@DarkSmile92
Copy link

@janpio Thanks for the quick help yesterday! :)

@Trainxy
Copy link
Author

Trainxy commented Nov 12, 2022

Thanks. Sorry that took so long to connect the dots, only the second time in the last 3 years this happened.

I'll wait for confirmation from @Trainxy to close the issue, or they can do that themselves.

@janpio Thanks for your help. I installed node_modules successfully after you solve.

@janpio janpio added bug/2-confirmed Bug has been reproduced and confirmed. and removed bug/0-unknown Bug is new, does not have information for reproduction or reproduction could not be confirmed. labels Nov 12, 2022
@janpio janpio added this to the 4.7.0 milestone Nov 12, 2022
@janpio janpio closed this as completed Nov 12, 2022
@janpio janpio changed the title Downloading binaries fails with wrong sha256 checksum Downloading binaries of 4.6.1 fails with wrong sha256 checksum Nov 12, 2022
@abrl91
Copy link

abrl91 commented Nov 25, 2022

  1. Are you trying to upgrade to 4.6.1 when this happens

Hey @janpio
we upgraded to Prisma 4.6.1 and got the following error (a few days ago):

 error: Error: Could not find prisma-fmt binary. Searched in ******/node_modules/@prisma/sdk/prisma-fmt-debian-openssl-3.0.x and ****/node_modules/@prisma/prisma-fmt-debian-openssl-3.0.x

Are you familiar with this issue?

@janpio
Copy link
Member

janpio commented Nov 25, 2022

Not really, please open a new issue and provide all the information.
Especially what command output this, and what it output before and after.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug/2-confirmed Bug has been reproduced and confirmed. kind/bug A reported bug. team/client Issue for team Client. team/schema Issue for team Schema. topic: engine download
Projects
None yet
Development

No branches or pull requests

9 participants