Skip to content

Conversation

@JSGette
Copy link
Contributor

@JSGette JSGette commented Feb 10, 2026

This is to address #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.

@google-cla
Copy link

google-cla bot commented Feb 10, 2026

Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

View this failed invocation of the CLA check for more information.

For the most up to date status, view the checks section at the bottom of the pull request.

@github-actions github-actions bot added the awaiting-review PR is awaiting review from an assigned reviewer label Feb 10, 2026
Copy link

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request addresses a NullPointerException that occurs when --repo_env is used with an environment variable that is not set. The fix involves adding a null check for the environment variable's value. If the value is null, a warning is issued, and the variable is ignored, preventing the crash. The change is correct and effectively resolves the issue.

@fmeum
Copy link
Collaborator

fmeum commented Feb 10, 2026

@bazel-io fork 9.0.1

@fmeum
Copy link
Collaborator

fmeum commented Feb 10, 2026

@bazel-io fork 9.1.0

Copy link
Collaborator

@fmeum fmeum left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you add test coverage to the tests touched by the culprit?

repoEnvBuilder.put(name, value);
nonstrictRepoEnvBuilder.put(name, value);
} else {
warnings.add(
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think we need to (or should) warn here, not being set is an entirely fine state to inherit.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I thought about it for a moment but then I remembered several occasions when envvars were leaking into build context and the only way to detect that was to compare 2 heavy execution logs. Also, this may be informative to quickly identify differences in local and CI environments. But I am fine to remove this

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

@JSGette
Copy link
Contributor Author

JSGette commented Feb 10, 2026

Could you add test coverage to the tests touched by the culprit?

Done

@JSGette JSGette force-pushed the jsgette/28605/fix_NPE_on_repo_env branch from 19deb3f to e94312a Compare February 10, 2026 12:43
Copy link
Collaborator

@fmeum fmeum left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

Copy link
Collaborator

@katre katre left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the fix!

@Wyverald Wyverald added awaiting-PR-merge PR has been approved by a reviewer and is ready to be merge internally and removed awaiting-review PR is awaiting review from an assigned reviewer labels Feb 10, 2026
@github-actions github-actions bot removed the awaiting-PR-merge PR has been approved by a reviewer and is ready to be merge internally label Feb 11, 2026
bazel-io pushed a commit to bazel-io/bazel that referenced this pull request Feb 11, 2026
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
bazel-io pushed a commit to bazel-io/bazel that referenced this pull request Feb 11, 2026
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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants