Set the default value of -check_direct_dependencies to error #21797
+1
−1
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.
What
Change the default value of --check_direct_dependencies from "warning" to "error":
Why
This feature has the potential to protect users from unexpected package upgrades and the unintended side effects that they can bring along, but it's not doing as much good as it can be by being a warning rather than an error. This is the sort of thing you don't know you need until it's already bitten you—setting it to an error will give people protection by default, and it's easy for them to opt out into a less safe mode of operation if they need to.
Here's the exact situation that I encountered last week:
rules_python
0.26.0rules_multirun
, which happens to userules_python
0.27.1rules_python
0.27.1, which broke some of our internal tooling and was unfortunately not caught prior to deploymentThis was arguably my fault: a warning was emitted, but I didn't happen to notice it in time. Even once I did see it, it was not clear what what had introduced the issue—the message doesn't explain why the resolved dependency graph didn't match the root module:
The good news is that
--check_direct_dependencies=error
already exists and solves this problem completely; when set, we get an error instead:If this had been an error, the source of the discrepancy would've been immediately obvious. Unless there are other implications to this change, I believe that changing the default value to
error
makes a lot of sense and would make Bazel safer and easier to operate, particularly in larger repositories with many dependencies and many contributors, not all of whom are necessarily Bazel experts.See also
Issue #21794 (reported by me; included for completeness)
Slack conversation