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

Bazel Unrecoverable Error with Capital Letters in SHA256 String #18291

Closed
alexbeattie42 opened this issue May 3, 2023 · 0 comments
Closed

Bazel Unrecoverable Error with Capital Letters in SHA256 String #18291

alexbeattie42 opened this issue May 3, 2023 · 0 comments
Labels
team-ExternalDeps External dependency handling, remote repositiories, WORKSPACE file. type: bug untriaged

Comments

@alexbeattie42
Copy link

Description of the bug:

If there is a capital letter present in the SHA256 string bazel crashes with the fatal error contained below. Some tools, specifically Get-FileHash on Windows return upper case SHA256 strings.

The Illegal hexadecimal character error message does not make it clear that the problem is that uppercase letters are not valid in a bazel SHA256 string.

The code should either be updated so that letter case doesn't matter or the error message should specifically state that upper case letters are not accepted.


java.lang.RuntimeException: Unrecoverable error while evaluating node 'REPOSITORY_DIRECTORY:@bazel_skylib' (requested by nodes 'PACKAGE_LOOKUP:@bazel_skylib//')
        at com.google.devtools.build.skyframe.AbstractParallelEvaluator$Evaluate.run(AbstractParallelEvaluator.java:642)
        at com.google.devtools.build.lib.concurrent.AbstractQueueVisitor$WrappedRunnable.run(AbstractQueueVisitor.java:382)
        at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
        at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
        at java.base/java.lang.Thread.run(Unknown Source)
Caused by: net.starlark.java.eval.Starlark$UncheckedEvalException: IllegalArgumentException thrown during Starlark evaluation (LOADING)
        at <starlark>.download_and_extract(<builtin>:0)
        at <starlark>._http_archive_impl(/private/var/tmp/_bazel_abeattie/6d30cdea4ede9832a87c4794c274b995/external/bazel_tools/tools/build_defs/repo/http.bzl:132)
Caused by: java.lang.IllegalArgumentException: Illegal hexadecimal character: D
        at com.google.common.hash.HashCode.decode(HashCode.java:360)
        at com.google.common.hash.HashCode.fromString(HashCode.java:346)
        at com.google.devtools.build.lib.bazel.repository.downloader.Checksum.fromString(Checksum.java:47)
        at com.google.devtools.build.lib.bazel.repository.starlark.StarlarkBaseExternalContext.validateChecksum(StarlarkBaseExternalContext.java:302)
        at com.google.devtools.build.lib.bazel.repository.starlark.StarlarkBaseExternalContext.downloadAndExtract(StarlarkBaseExternalContext.java:650)
        at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
        at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
        at java.base/java.lang.reflect.Method.invoke(Unknown Source)
        at net.starlark.java.eval.MethodDescriptor.call(MethodDescriptor.java:162)
        at net.starlark.java.eval.BuiltinFunction.fastcall(BuiltinFunction.java:77)
        at net.starlark.java.eval.Starlark.fastcall(Starlark.java:638)
        at net.starlark.java.eval.Eval.evalCall(Eval.java:682)
        at net.starlark.java.eval.Eval.eval(Eval.java:497)
        at net.starlark.java.eval.Eval.execAssignment(Eval.java:109)
        at net.starlark.java.eval.Eval.exec(Eval.java:268)
        at net.starlark.java.eval.Eval.execStatements(Eval.java:82)
        at net.starlark.java.eval.Eval.execFunctionBody(Eval.java:66)
        at net.starlark.java.eval.StarlarkFunction.fastcall(StarlarkFunction.java:173)
        at net.starlark.java.eval.Starlark.fastcall(Starlark.java:638)
        at net.starlark.java.eval.Starlark.call(Starlark.java:604)
        at com.google.devtools.build.lib.bazel.repository.starlark.StarlarkRepositoryFunction.fetch(StarlarkRepositoryFunction.java:220)
        at com.google.devtools.build.lib.rules.repository.RepositoryDelegatorFunction.fetchRepository(RepositoryDelegatorFunction.java:413)
        at com.google.devtools.build.lib.rules.repository.RepositoryDelegatorFunction.compute(RepositoryDelegatorFunction.java:344)
        at com.google.devtools.build.skyframe.AbstractParallelEvaluator$Evaluate.run(AbstractParallelEvaluator.java:571)
        at com.google.devtools.build.lib.concurrent.AbstractQueueVisitor$WrappedRunnable.run(AbstractQueueVisitor.java:382)
        at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
        at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
        at java.base/java.lang.Thread.run(Unknown Source)

What's the simplest, easiest way to reproduce this bug? Please provide a minimal example if possible.

Fails:

http_archive(
    name = "bazel_skylib",
    sha256 = "74D544D96F4A5BB630D465CA8BBCFE231E3594E5AAE57E1EDBF17A6EB3CA2506",
    urls = [
        "https://storage.googleapis.com/mirror.tensorflow.org/github.com/bazelbuild/bazel-skylib/releases/download/1.3.0/bazel-skylib-1.3.0.tar.gz",
        "https://github.com/bazelbuild/bazel-skylib/releases/download/1.3.0/bazel-skylib-1.3.0.tar.gz",
    ],
)

Succeeds:

http_archive(
    name = "bazel_skylib",
    sha256 = "74d544d96f4a5bb630d465ca8bbcfe231e3594e5aae57e1edbf17a6eb3ca2506",
    urls = [
        "https://storage.googleapis.com/mirror.tensorflow.org/github.com/bazelbuild/bazel-skylib/releases/download/1.3.0/bazel-skylib-1.3.0.tar.gz",
        "https://github.com/bazelbuild/bazel-skylib/releases/download/1.3.0/bazel-skylib-1.3.0.tar.gz",
    ],
)

Which operating system are you running Bazel on?

Windows & MacOS

What is the output of bazel info release?

6.1.1

If bazel info release returns development version or (@non-git), tell us how you built Bazel.

No response

What's the output of git remote get-url origin; git rev-parse master; git rev-parse HEAD ?

No response

Have you found anything relevant by searching the web?

No response

Any other information, logs, or outputs that you want to share?

No response

@sgowroji sgowroji added the team-ExternalDeps External dependency handling, remote repositiories, WORKSPACE file. label May 3, 2023
iancha1992 pushed a commit to iancha1992/bazel that referenced this issue May 15, 2023
Fixes this crash when e.g. the `sha256` attribute is passed an upper case string:

```
Caused by: java.lang.IllegalArgumentException: Illegal hexadecimal character: D
        at com.google.common.hash.HashCode.decode(HashCode.java:360)
        at com.google.common.hash.HashCode.fromString(HashCode.java:346)
        at com.google.devtools.build.lib.bazel.repository.downloader.Checksum.fromString(Checksum.java:47)
        at com.google.devtools.build.lib.bazel.repository.starlark.StarlarkBaseExternalContext.validateChecksum(StarlarkBaseExternalContext.java:302)
        at com.google.devtools.build.lib.bazel.repository.starlark.StarlarkBaseExternalContext.downloadAndExtract(StarlarkBaseExternalContext.java:650)
        ...
```

Fixes bazelbuild#18291

Closes bazelbuild#18305.

PiperOrigin-RevId: 529601921
Change-Id: I75deee47bcac80ee81603591c22f43d013ba0c29
fweikert pushed a commit to fweikert/bazel that referenced this issue May 25, 2023
Fixes this crash when e.g. the `sha256` attribute is passed an upper case string:

```
Caused by: java.lang.IllegalArgumentException: Illegal hexadecimal character: D
        at com.google.common.hash.HashCode.decode(HashCode.java:360)
        at com.google.common.hash.HashCode.fromString(HashCode.java:346)
        at com.google.devtools.build.lib.bazel.repository.downloader.Checksum.fromString(Checksum.java:47)
        at com.google.devtools.build.lib.bazel.repository.starlark.StarlarkBaseExternalContext.validateChecksum(StarlarkBaseExternalContext.java:302)
        at com.google.devtools.build.lib.bazel.repository.starlark.StarlarkBaseExternalContext.downloadAndExtract(StarlarkBaseExternalContext.java:650)
        ...
```

Fixes bazelbuild#18291

Closes bazelbuild#18305.

PiperOrigin-RevId: 529601921
Change-Id: I75deee47bcac80ee81603591c22f43d013ba0c29
keertk pushed a commit that referenced this issue Jun 5, 2023
Fixes this crash when e.g. the `sha256` attribute is passed an upper case string:

```
Caused by: java.lang.IllegalArgumentException: Illegal hexadecimal character: D
        at com.google.common.hash.HashCode.decode(HashCode.java:360)
        at com.google.common.hash.HashCode.fromString(HashCode.java:346)
        at com.google.devtools.build.lib.bazel.repository.downloader.Checksum.fromString(Checksum.java:47)
        at com.google.devtools.build.lib.bazel.repository.starlark.StarlarkBaseExternalContext.validateChecksum(StarlarkBaseExternalContext.java:302)
        at com.google.devtools.build.lib.bazel.repository.starlark.StarlarkBaseExternalContext.downloadAndExtract(StarlarkBaseExternalContext.java:650)
        ...
```

Fixes #18291

Closes #18305.

PiperOrigin-RevId: 529601921
Change-Id: I75deee47bcac80ee81603591c22f43d013ba0c29

Co-authored-by: Fabian Meumertzheim <fabian@meumertzhe.im>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
team-ExternalDeps External dependency handling, remote repositiories, WORKSPACE file. type: bug untriaged
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants