pip extension facts structure prevents correct git merge of MODULE.bazel.lock
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 4/5
- Tempo stimato
- 3-5 giorni
- Idoneità per principianti
- 48/100
- Tipo di issue
- Bug
- Chiarezza
- Abbastanza chiara
- Stato di attività
- Attiva
- Stack tecnologico
- python
- Ambito
- build-system
Direzione di ricerca
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.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
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.
- Lingua principale
- Starlark
- Stelle
- 690
- Fork
- 722
- Merge medio
- 1g 2h
- PR unite (30g)
- 50
Guida per i contributori
Apri la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di bazel-contrib/rules_python
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
bazel-contrib/rules_python#4164 · 1 commento ·
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
bazel-contrib/rules_python#3821 ·
-
Release 2.4.0 Apertatype: release
Difficoltà 4/5 3-5 giorni Idoneità per principianti 25/100
bazel-contrib/rules_python#4175 · 3 commenti ·
-
Release 2.3.4 Apertatype: release
Difficoltà 2/5 1-3 ore Idoneità per principianti 35/100
bazel-contrib/rules_python#4173 · 2 commenti ·
-
Difficoltà 3/5 1-2 giorni Idoneità per principianti 70/100
bazel-contrib/rules_python#4171 ·
Tutte le issue di bazel-contrib/rules_python
Issue simili
-
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 85/100
-
CS0162 "Unreachable code detected" warning from a MSBuildTemp .tmp file in every game project Apertabug
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 90/100
-
area:engineering priority:p2 type:bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 75/100
jejjohnson/pyrox#234 ·
-
good first issue
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 90/100
-
good first issue
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 85/100
ros2/ros2_tracing#266 · 1 commento ·