[9.1.0] Fix NPE caused by --repo_env with no value set (https://github.com/bazelbuild/bazel/pull/28606)#28641
Merged
iancha1992 merged 1 commit intobazelbuild:release-9.1.0from Feb 26, 2026
Conversation
This is to address bazelbuild#28605. bazel crashes with `NullPointerException` in case `--repo_env=NON_EXISTENT` is used with no value set in user's local environment. It worked in `8.5.1` but doesn't in `9.0.0` so it seems like a regression. Closes bazelbuild#28606. PiperOrigin-RevId: 868871905 Change-Id: I0ecd9a4b76b7795e1f00583050aaf343fe930832
There was a problem hiding this comment.
Code Review
This pull request effectively resolves a NullPointerException that occurred when --repo_env was used with an environment variable that was not set. The fix in CommandEnvironment.java correctly adds a null check before attempting to add the variable to the repository environment map. The new test case in bazel_external_repository_test.py is well-designed, accurately reproduces the failure condition, and will prevent future regressions. The changes are clean, targeted, and fully address the reported issue.
katre
approved these changes
Feb 12, 2026
Wyverald
approved these changes
Feb 25, 2026
Merged
via the queue into
bazelbuild:release-9.1.0
with commit Feb 26, 2026
812045d
46 checks passed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This is to address #28605. bazel crashes with
NullPointerExceptionin case--repo_env=NON_EXISTENTis used with no value set in user's local environment. It worked in8.5.1but doesn't in9.0.0so it seems like a regression.Closes #28606.
PiperOrigin-RevId: 868871905
Change-Id: I0ecd9a4b76b7795e1f00583050aaf343fe930832
Commit b55b69d