Skip to content

Using --repo_env without a value set leads to NPE #28605

@JSGette

Description

@JSGette

Description of the bug:

Steps to reproduce

  1. Add a --repo_env flag to one of the configurations in .bazelrc or a build command. --repo_env=NPM_CONFIG_REGISTRY
  2. Ensure that it is not actually set in the local environment. Bazel crashes with NullPointerException:
OpenJDK 64-Bit Server VM warning: Options -Xverify:none and -noverify were deprecated in JDK 13 and will likely be removed in a future release.
FATAL: bazel crashed due to an internal error. Printing stack trace:
java.lang.NullPointerException: null value in entry: npm_config_registry=null
	at com.google.common.collect.CollectPreconditions.checkEntryNotNull(CollectPreconditions.java:32)
	at com.google.common.collect.RegularImmutableMap.fromEntryArrayCheckingBucketOverflow(RegularImmutableMap.java:130)
	at com.google.common.collect.RegularImmutableMap.fromEntryArray(RegularImmutableMap.java:96)
	at com.google.common.collect.RegularImmutableMap.fromEntries(RegularImmutableMap.java:79)
	at com.google.common.collect.ImmutableMap.copyOf(ImmutableMap.java:729)
	at com.google.common.collect.ImmutableMap.copyOf(ImmutableMap.java:702)
	at com.google.devtools.build.lib.runtime.CommandEnvironment.<init>(CommandEnvironment.java:412)
	at com.google.devtools.build.lib.runtime.BlazeWorkspace.initCommand(BlazeWorkspace.java:333)
	at com.google.devtools.build.lib.runtime.BlazeCommandDispatcher.execExclusively(BlazeCommandDispatcher.java:371)
	at com.google.devtools.build.lib.runtime.BlazeCommandDispatcher.exec(BlazeCommandDispatcher.java:266)
	at com.google.devtools.build.lib.server.GrpcServerImpl.executeCommand(GrpcServerImpl.java:608)
	at com.google.devtools.build.lib.server.GrpcServerImpl.lambda$run$0(GrpcServerImpl.java:679)
	at io.grpc.Context$1.run(Context.java:566)
	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)

It used to work in 8.5.1.

Which category does this issue belong to?

Configurability

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

No response

Which operating system are you running Bazel on?

macos 26

What is the output of bazel info release?

No response

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

bazel info release crashes as well:

Starting local Bazel server (9.0.0) and connecting to it...

Server terminated abruptly (error code: 14, error message: 'Socket closed', log file: '/Users/joseph.gette/Library/Caches/bazel/_bazel_joseph.gette/d8e9195c7180b82e81d7a40033183593/server/jvm.out')

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


If this is a regression, please try to identify the Bazel commit where the bug was introduced with bazelisk --bisect.

Looks like this is the culprit:
863d5ce

Have you found anything relevant by searching the web?

No response

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

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions