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

Unhelpful error message when using the wrong sha in http_archive() #6089

Closed
hansl opened this issue Sep 5, 2018 · 9 comments
Closed

Unhelpful error message when using the wrong sha in http_archive() #6089

hansl opened this issue Sep 5, 2018 · 9 comments
Assignees
Labels
more data needed team-ExternalDeps External dependency handling, remote repositiories, WORKSPACE file.

Comments

@hansl
Copy link

hansl commented Sep 5, 2018

Using the wrong SHA in http_archive() will result in the following message (using rules_nodejs as an example):

$ bazel build //...
INFO: Starting clean.
Starting local Bazel server and connecting to it...
..............
ERROR: error loading package '': Encountered error while reading extension file 'internal/common/check_version.bzl': no such package '@build_bazel_rules_nodejs//internal/common': Prefix rules_nodejs-0.12.2 was given, but not found in the zip
ERROR: error loading package '': Encountered error while reading extension file 'internal/common/check_version.bzl': no such package '@build_bazel_rules_nodejs//internal/common': Prefix rules_nodejs-0.12.2 was given, but not found in the zip
INFO: Elapsed time: 1.645s
INFO: 0 processes.
FAILED: Build did NOT complete successfully (0 packages loaded)

This fails to give me any relevant information to the error. Instead, it gives me actual misinformation (that the zip doesn't contain the prefix, which is wrong).

A better error message would include wording such as "the ZIP downloaded does not match the SHA expected".

@ittaiz
Copy link
Member

ittaiz commented Sep 5, 2018 via email

@irengrig
Copy link
Contributor

irengrig commented Sep 5, 2018

Hi! Thank you for reporting the issue.
Actually the message that you copied complains about wrong prefix:
"ERROR: error loading package '': Encountered error while reading extension file 'internal/common/check_version.bzl': no such package '@build_bazel_rules_nodejs//internal/common': Prefix rules_nodejs-0.12.2 was given, but not found in the zip"
and not about the SHA, seems the SHA was correct (the issue about improving the SHA message: #3709)

I was also recently thinking that maybe we should also suggest what probable value of the prefix should be, it is easy to detect. Did you mean that?

@irengrig irengrig added team-ExternalDeps External dependency handling, remote repositiories, WORKSPACE file. untriaged labels Sep 5, 2018
@irengrig irengrig self-assigned this Sep 5, 2018
@hansl
Copy link
Author

hansl commented Sep 5, 2018

No. The only thing I changed to fix this error was the SHA argument in http_archive. Nothing else was involved.

@irengrig
Copy link
Contributor

irengrig commented Sep 5, 2018

Can not reproduce that. I tried to change the SHA in my example to incorrect value and it complains about SHA. Can you provide more information? Thank you.

@Globegitter
Copy link

I imagine that probably a valid sha was entered of an archive that existed in the cache, so bazel loaded that but the contents did not match. As far as I am aware @aehlig is doing work on that topic, that bazel actually verifies the sha of remote repositories and does not just rely on the one specified.

@irengrig
Copy link
Contributor

irengrig commented Sep 6, 2018

I see, thank you!

@dslomov dslomov added P2 We'll consider working on this in future. (Assignee optional) type: bug and removed untriaged labels Sep 10, 2018
@aehlig aehlig added more data needed and removed P2 We'll consider working on this in future. (Assignee optional) type: bug labels Nov 7, 2018
@aehlig aehlig assigned aehlig and unassigned irengrig and aehlig Nov 7, 2018
@aehlig
Copy link
Contributor

aehlig commented Nov 7, 2018

This is a bit of a tricky issue, as technically it is working as intended: bazel should avoid all call outs to the network, if it can. Now, if a hash is provided, this is not only a security measure, but also a promise to bazel that any file with that hash will do, no matter where it is fetched from. So the cache hit is legitimate and calling out to the network just to improve the error message in case the user made a mistake in the WOKRSPACE file is not a good experience.

Now, I don't know of any good semantics for bazel that would improve the error message without adding additional cost on the non-error case. And I don't like optimising the error case at the cost of the normal case. If you have an idea how bazel could behave better (again: without degrading the non-error case), feel free to file a feature request or reopen this issue with more details.

@aehlig aehlig closed this as completed Nov 7, 2018
@aehlig
Copy link
Contributor

aehlig commented Nov 7, 2018

This is a duplicate. Don’t remember the other issue but you can search for it

Probably #5144

@aehlig
Copy link
Contributor

aehlig commented Nov 7, 2018

...or #5045

@philwo philwo added the team-OSS Issues for the Bazel OSS team: installation, release processBazel packaging, website label Jun 15, 2020
@philwo philwo removed the team-OSS Issues for the Bazel OSS team: installation, release processBazel packaging, website label Nov 29, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
more data needed team-ExternalDeps External dependency handling, remote repositiories, WORKSPACE file.
Projects
None yet
Development

No branches or pull requests

7 participants