VEX product detection fails on Poetry 2 projects that declare dynamic = ["version"] with the version in [tool.poetry], so scan --vex exits 1 after rewriting poetry.lock
I maintainer di solito rispondono entro 1 giorno
Una pull request collegata è già stata integrata.
- #1529 di @mikolalysenko — integrata
Valutazione
- Difficoltà
- 3/5
- Tempo stimato
- Mezza giornata
- Idoneità per principianti
- 25/100
Direzione di ricerca
Start in crates/socket-patch-core/src/vex/product.rs, at parse_pyproject and scan_toml_section, to see why name and version must come from one section. Reproduce with the layout in the issue, then run socket-patch vex -O v.json in a directory with no git origin. Done when that command yields pkg:pypi/[email protected] without --product. The test pattern is in crates/socket-patch-cli/tests/in_process_redirect_poetry.rs. Linked PR #1529 is already open against this bug.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
[agent] Found by the scheduled Poetry bug-hunt routine (ledger #311).
Summary
Poetry 2 documents a PEP 621 layout where [project] has name and dynamic = ["version"], and the version is in [tool.poetry] version (see https://python-poetry.org/docs/pyproject/#version). poetry check, poetry version and poetry build all accept it (demo 0.3.0, demo-0.3.0-py3-none-any.whl).
vex/product.rs::parse_pyproject reads name and version from one section only. It tries [project], which has no version, and then [tool.poetry], which has no name. Both return None, so no product is detected:
socket-patch vex -O out.jsonexits 2 withproduct_undetected("pyproject.toml was found but has no usable name and version").socket-patch scan --mode hosted --vex out.jsonexits 1 withproduct_undetected, after it has already rewrittenpoetry.lockto the hosted pin. No VEX document is written.
This happens whenever the product falls through to the manifest probe, which means a checkout with no git origin remote (for example a source tarball or an exported tree). A git remote takes priority in detect_product.
This isn't the same as #642. That issue is about a missing [tool.pdm] fallback. Here both sections are read, but their keys are never combined.
Impact
- Any Poetry 2 project that uses the documented dynamic-version layout gets no VEX unless the user passes
--productby hand, andscan --vexturns a successful hosted rewrite into a failed command (exit 1) in CI. - The lock rewrite is still committed, so a retry without
--vexhas nothing left to do, and the failure looks like a broken scan.
Repro (Linux, Poetry 2.0.1 / 2.2.1 / 2.5.1, no git checkout)
A local mock of the patch API serves a hosted patch for pkg:pypi/[email protected] (same routes as crates/socket-patch-cli/tests/in_process_redirect_poetry.rs). Any patched dependency would do.
mkdir demo-proj && cd demo-proj && mkdir demo && touch demo/__init__.py
cat > pyproject.toml <<'EOF'
[project]
name = "demo"
dynamic = ["version"]
requires-python = ">=3.9"
dependencies = ["six==1.16.0"]
[tool.poetry]
version = "0.3.0"
[build-system]
requires = ["poetry-core>=2.0.0"]
build-backend = "poetry.core.masonry.api"
EOF
poetry check # All set!
poetry version # demo 0.3.0
poetry lock
socket-patch scan --mode hosted --json --vex out.vex.json
# exit 1, status "error", error.code "product_undetected"
# poetry.lock now carries the hosted pin; out.vex.json not written
socket-patch vex -O v.json # exit 2, product_undetected
socket-patch vex -O v.json --product pkg:pypi/[email protected] # exit 0 (workaround)
Control: with version = "0.3.0" in [project] (no dynamic, no [tool.poetry]), scan --mode hosted --vex exits 0 and the product is pkg:pypi/[email protected].
Expected vs actual
- Expected:
vex --helpdocuments auto-detection from "pyproject.toml: pkg:pypi/@". For a project Poetry itself builds asdemo 0.3.0, the product should bepkg:pypi/[email protected]:[project].name, plus the[tool.poetry].versionthat Poetry uses whenversionis listed in[project].dynamic. CLI_CONTRACT.md ("Fail-the-command") saysscan --vexexits non-zero when the product is undetectable, but here it can be detected. - Actual:
product_undetected.vexexits 2, andscan --vexexits 1 after it has written the lock.
OS × version
| OS | Poetry | Result |
|---|---|---|
| Linux | 2.0.1 | fail (2/2) |
| Linux | 2.2.1 | fail |
| Linux | 2.5.1 | fail (2/2) |
| Linux | 2.5.1, static [project].version (control) |
pass |
| macOS / Windows | any | untested. The code path doesn't depend on the OS (pure TOML text scan). |
Poetry 1.x ignores [project], so the layout only applies to Poetry ≥ 2.0.
Suspect code
crates/socket-patch-core/src/vex/product.rs:157-165(parse_pyproject):scan_toml_section(content, "project").or_else(|| scan_toml_section(content, "tool.poetry"))needs both keys from the same section. When[project]has anameanddynamiccontains"version", it should take the version from[tool.poetry].crates/socket-patch-core/src/vex/product.rs:368(scan_toml_section) returns nothing unless both keys are present.
Main 6a06ddd. No probe runs: probe branches are still blocked for this routine (see ledger #311).
- Lingua principale
- Rust
- Stelle
- 8
- Fork
- 1
- Merge medio
- 16h 18m
- PR unite (30g)
- 587
Preparare l'ambiente
- Nessun Dockerfile né file Docker Compose
- Nessun modello di pull request
- Leggi 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 SocketDev/socket-patch
-
agent:triaged bug bughunt pm:pipenv priority:p1
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
SocketDev/socket-patch#1608 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
-
agent:triaged bug bughunt pm:vlt priority:p1
Difficoltà 2/5 1-3 ore Idoneità per principianti 62/100
SocketDev/socket-patch#1601 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
-
agent:triaged bug bughunt pm:npm priority:p3 ux
Difficoltà 2/5 1-3 ore Idoneità per principianti 75/100
SocketDev/socket-patch#1072 · 2 commenti ·
I maintainer di solito rispondono entro 1 giorno
-
agent:triaged bug bughunt pm:yarn-berry priority:p1
Difficoltà 2/5 1-3 ore Idoneità per principianti 73/100
SocketDev/socket-patch#783 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
-
Vendored cargo warns cargo_multi_version_old_cargo ("declares no rust-version") when the root package inherits rust-version from [workspace.package]Forse già presa @mikolalysenko l’ha presa 4 giorni fa. Apertaagent:triaged bug bughunt pm:cargo priority:p2
Difficoltà 2/5 1-3 ore Idoneità per principianti 84/100
SocketDev/socket-patch#651 · 3 commenti ·
I maintainer di solito rispondono entro 1 giorno
Tutte le issue di SocketDev/socket-patch
Issue simili
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
EmbarkStudios/cargo-deny#910 ·
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 68/100
tursodatabase/turso#10054 ·
I maintainer di solito rispondono entro 1 giorno
-
build: Update rust versionForse già presa Una pull request collegata a questa issue è aperta o già unita. Apertadependencies
Difficoltà 2/5 1-3 ore Idoneità per principianti 67/100
ibm-granite-community/granite-cli#229 ·
I maintainer di solito rispondono entro 1 giorno
-
setTargetAtTime booked ahead of time starts its curve early (values blow up before start_time)Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
orottier/web-audio-api-rs#658 ·
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 84/100
aosama/astronomical#1318 ·
I maintainer di solito rispondono entro 1 giorno