Handling yanked module version in the BCR #128
Replies: 3 comments 19 replies
-
This is only the case if we don't pin the commit of the registry that is used. If the commit from the registry is pinned then this issue goes away? |
Beta Was this translation helpful? Give feedback.
-
The problem with this approach is this creates a forward maintainance burden; when |
Beta Was this translation helpful? Give feedback.
-
I think the reproducibility is essential, and also users can't be forced to upgrade immediately. I'd prefer a variation on Solution 1:
|
Beta Was this translation helpful? Give feedback.
-
In the original Bzlmod design doc: Bazel External Dependencies Overhaul, we planned to implement the yanked version feature in the BCR. Currently, this is still a no-op even if we add a yanked version into the metadata.json file.
In the original design, we basically put "Bazel throws an error when the yanked version ends up in the resolved graph. If a lock file is used, Bazel will still be able to fetch the source archive." But as brought up in #81 (comment), there are more design choices and details to explore for this feature.
In general, we have to balance between "preventing users from depending on the yanked version" vs "build reproducibility".
I think there are two potentially viable solutions:
Solution 1 (updated with input from @alexeagle )
Add the yanked version and yanked reason in the metadata.json file of the module. Eg.
"yanked_versions": {"1.2.11": "zlib 1.2.11 is yanked due to CVE-2018-25032, please upgrade to 1.2.12"}
If a yanked version appears in the resolved dependency graph, Bazel throws an error, which contains the yanked reason and the way to resolve/suppress the error.
Then users can upgrade the module to a new version by adding a
bazel_dep(name = "foo", version = "<new_version>")
statement in the MODULE.bazel file.In case the module is not a direct dependency, users can add
bazel_dep(name = "foo", version = "<new_version>", repo_name=None)
, which upgrades the module version but doesn't give any repo visibility from the root module.Users can also suppress the error by adding
--allow_yanked_version=<module_name>@<version>
or setBZLMOD_ALLOW_YANKED_VERSION=<module_name>@<version>
env var, then Bazel prints a warning about the suppression, and the build can continue.Pros
Cons
bazel_dep
to upgrade the module. Mitigate: In case the module is a direct dependency, update thebazel_dep
directive is what the expected solution anyway, in case it's not, usingrepo_name=None
withbazel_dep
can still update the module and still follow strict deps.Solution 2
"yanked_versions": {"1.2.11": "1.2.12"}
Pros
Cons
In both solutions, if a lock file is used, users would still be able to download the source archive of the yanked dependency. This is similar to cargo: https://doc.rust-lang.org/cargo/commands/cargo-yank.html Basically, lock file can prevent any breakages caused by the BCR content change because dependency resolution is skipped.
Feel free to share your opinions on this or propose other possible solutions!
Beta Was this translation helpful? Give feedback.
All reactions