pip extension facts structure prevents correct git merge of MODULE.bazel.lock
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 4/5
- Thời gian dự kiến
- 3-5 ngày
- Mức phù hợp với người mới
- 48/100
- Loại issue
- Lỗi
- Độ rõ ràng
- Khá rõ ràng
- Mức độ hoạt động
- Sôi nổi
- Công nghệ
- python
- Lĩnh vực
- build-system
Hướng nghiên cứu
Start in python/extensions:pip.bzl and inspect how pip facts are written into MODULE.bazel.lock, then read scripts/bazel-lockfile-merge.jq to confirm the shallow merge behavior. Reproduce concurrent dependency additions and verify that the merged lockfile retains both packages and remains up to date.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
Summary
The pip extension stores its facts with the index URL as a top-level key and package names one level deeper:
{
"@@rules_python+//python/extensions:pip.bzl%pip": {
"dist_hashes": {
"https://pypi.org/simple/": {
"package-a": { "wheel_path": "sha256:..." },
"package-b": { "wheel_path": "sha256:..." }
}
},
"index_urls": {
"https://pypi.org/simple/": {
"package-a": "package-a"
}
}
}
}
Bazel ships a git merge driver for MODULE.bazel.lock (scripts/bazel-lockfile-merge.jq) that merges the facts section using shallow_merge, which applies last-wins semantics at the top level only (jq add).
Because dist_hashes and index_urls are single top-level keys shared by all packages, when two branches each add a different package, one branch's entire dist_hashes map overwrites the other's. The merged lockfile is missing the packages from one branch, causing:
MODULE.bazel.lock is no longer up-to-date because the extension
'@@rules_python+//python/extensions:pip.bzl%pip' has changed its facts
Root cause
This is a mismatch between the facts structure and the merge driver's semantics. I filed https://github.com/bazelbuild/bazel/issues/31139 requesting a deep-merge for facts, but the Bazel team considers shallow_merge intentional — deep-merging arbitrary extension facts could be wrong for other extensions — and redirected to rules_python.
Suggested fix
If the facts structure used package names (or index_url + package name) as top-level keys, shallow_merge would correctly preserve entries from both branches:
{
"@@rules_python+//python/extensions:pip.bzl%pip": {
"https://pypi.org/simple/ package-a": { "wheel_path": "sha256:..." },
"https://pypi.org/simple/ package-b": { "wheel_path": "sha256:..." }
}
}
Any flattening that puts per-package data under distinct top-level keys would solve the problem.
Impact
This affects any team that uses a CI setup where master is merged into PR branches before running tests (common in Jenkins-based pipelines), and where two concurrent PRs each add a Python dependency.
- Ngôn ngữ chính
- Starlark
- Star
- 690
- Fork
- 722
- Merge trung bình
- 1 ngày 55 phút
- Pull request đã merge (30 ngày)
- 38
Hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của bazel-contrib/rules_python
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 70/100
bazel-contrib/rules_python#4179 ·
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
bazel-contrib/rules_python#4164 · 1 bình luận ·
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
bazel-contrib/rules_python#3821 ·
-
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 45/100
bazel-contrib/rules_python#4181 ·
-
Release 2.4.0 Đang mởtype: release
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 25/100
bazel-contrib/rules_python#4175 · 3 bình luận ·
Tất cả issue của bazel-contrib/rules_python
Issue tương tự
-
Name consistency Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 75/100
eellak/triplestore#65 · 1 bình luận ·
-
litertlm-android AAR ships no consumer ProGuard rules → "mid == null" SIGABRT in minified apps Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 70/100
google-ai-edge/LiteRT-LM#3739 ·
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 70/100
-
area-Bzlmod team-ExternalDeps type: bug untriaged
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 65/100
bazelbuild/bazel#31291 · 2 bình luận ·
-
bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 75/100
bradcypert/plum#53 ·