Repository navigation
Description
[agent] Found by the scheduled Poetry bug-hunt routine (ledger #311).
Summary
On Poetry 1.4–1.8 with installer.modern-installation = false (Poetry's legacy pip-based installer, set in poetry.toml, the global config or POETRY_INSTALLER_MODERN_INSTALLATION=false), a warm virtualenv keeps the upstream bytes after a hosted or vendored rewrite of poetry.lock. poetry install prints Updating six (1.16.0 -> 1.16.0 <patched wheel>) and records the patched wheel in direct_url.json, but six.py keeps its upstream bytes. A second poetry install says "No dependencies to install or update".
socket-patch decides whether to warn about this from the lock's writer only (is_pre_1_4()). A lock stamped 1.4–1.8 is treated as "replaces a same-version install", so:
- Vendored:
scan --mode vendoredprints no stale-install warning. The next step it gives ("Reinstall from the updated lockfile, then runsocket-patch vex") leaves the package unpatched.vexthen attestsnot_affectedfrom the committed artifact (by design) and warnsvendored_tree_out_of_sync, whose remedy ("re-run your package manager's install to resync it") does nothing here. The user ends up with anot_affectedVEX document while the code that runs is unpatched, and every remedy they're given is a no-op. - Hosted:
vexfails closed (good). But the scan warning only says "Poetry before 1.4 may keep same-version packages", andvex's advice ("Reinstall from the lockfile") doesn't work either, so the user has to guess.
A fresh virtualenv installs the patched wheel correctly. With modern-installation = true (the default), the same steps replace the package. This is the same bug class as #2302 (pip) and #641 (PDM < 2.11), and the apply-side counterpart of #2320 (Poetry 1.1–1.3 rollback).
Repro (Linux, Poetry 1.8.5, real PyPI, local mock of the patch API serving a patched six 1.16.0 wheel)
mkdir mi && cd mi
cat > pyproject.toml <<'EOF'
[tool.poetry]
name = "mi"
version = "0.1.0"
description = ""
authors = ["x <x@example.com>"]
package-mode = false
[tool.poetry.dependencies]
python = "^3.9"
six = "1.16.0"
EOF
poetry config virtualenvs.in-project true --local
poetry config installer.modern-installation false --local
poetry lock && poetry install # warm venv, upstream six
socket-patch scan --mode vendored --yes # no stale-install warning
poetry install # "- Updating six (1.16.0 -> 1.16.0 .socket/vendor/pypi/<uuid>/six-1.16.0-py2.py3-none-any.whl)"
grep -c SOCKET-PATCHED .venv/lib/python3.11/site-packages/six.py # 0: upstream bytes
poetry install # "No dependencies to install or update"
socket-patch vex # exit 0, not_affected (vendored); warns vendored_tree_out_of_sync: "re-run your package manager's install to resync it"The hosted variant (scan --mode hosted) behaves the same on install. There vex exits 1 with "Reinstall from the lockfile", which doesn't help.
Expected
docs/testing/poetry-compatibility.md("Installer boundaries") says Poetry 1.4–1.8 replace an already-installed same-version package. That holds only for the modern installer.- A stale-install risk should be flagged the way it is for pre-1.4 writers (
redirect_poetry_stale_install_risk/pypi_poetry_integrity_unverified), with a remedy that works: recreate the venv, orpip uninstall sixbeforepoetry install, orpoetry run pip install --force-reinstall --no-deps <wheel>. The same applies to thevendored_tree_out_of_syncand hostedvexadvice.CLI_CONTRACT.mdalready makes these remedies tool-specific for Hatch, PDM < 2.11 and gems.
Actual
No warning on vendored. A generic warning on hosted that names only pre-1.4 Poetry. The remedies given don't work, and the vendored VEX says not_affected over an unpatched install.
Versions
| Poetry | modern-installation |
Mode | Warm poetry install gets patched bytes |
vex |
|---|---|---|---|---|
| 1.8.5 | false | vendored | no (2 runs) | exit 0, not_affected + out-of-sync warning |
| 1.8.5 | false | hosted | no (2 runs) | exit 1, fail-closed |
| 1.4.2 | false | vendored | no | exit 0, not_affected + out-of-sync warning |
| 1.4.2 | false | hosted | no | exit 1 |
| 1.8.5 / 1.4.2 | true (default) | hosted / vendored | yes | exit 0 |
| 1.8.5 | false | vendored, fresh venv | yes | exit 0 |
Tested on main cfc870f. Not a regression: the routine saw the same installer behavior on 2026-10-02. Poetry 2.x removed the setting, so 2.x isn't affected. Linux only. macOS and Windows should behave the same, since this is Poetry/pip logic and not platform-specific.
The rollback direction (vendored vendor --revert / hosted rollback, then poetry install with the legacy installer) very likely keeps the patched bytes too, as in #2320. That wasn't measured in this run.
Suspect code
crates/socket-patch-core/src/vendor/pypi_poetry.rs:128(pre_1_4_writer: lock writer only, no Poetry config read)crates/socket-patch-core/src/patch/redirect/poetry.rs:146(stale_writer/is_pre_1_4())crates/socket-patch-cli/src/commands/vex.rs:2147(genericvendored_tree_out_of_syncremedy)docs/testing/poetry-compatibility.md:66(the 1.4–1.8 boundary row)
Generated by Claude Code
Activity