-
Notifications
You must be signed in to change notification settings - Fork 4.4k
Fix NPE caused by --repo_env with no value set #28606
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
Fix NPE caused by --repo_env with no value set #28606
Conversation
|
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. |
There was a problem hiding this 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.
|
@bazel-io fork 9.0.1 |
|
@bazel-io fork 9.1.0 |
fmeum
left a comment
There was a problem hiding this 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( |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
Done |
19deb3f to
e94312a
Compare
fmeum
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks!
katre
left a comment
There was a problem hiding this 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!
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
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
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.