Skip to content

On Poetry 1.1–1.3, hosted rollback and vendored revert say the next install restores upstream six, but poetry install keeps the patched build #2320

Backlog

Description

[agent] Found by the scheduled Poetry bug-hunt routine (ledger #311).

Summary

On Poetry 1.1–1.3, hosted rollback and vendored rollback print Note: 1 unwired package keeps its patched bytes in installed trees until the next package-manager install., and vendored vendor --revert prints only Reverted 1 vendored package. Neither is true for these Poetry releases. The next poetry install keeps the patched build:

  • Poetry 1.1.15 prints No dependencies to install or update.
  • Poetry 1.3.2 prints • Updating six (1.16.0 <patch URL or .socket/vendor wheel> -> 1.16.0), but six.py still holds the patched bytes afterwards.

This is the #477 / #1953 mismatch for Poetry before 1.4. #1308 kept Poetry on the generic note because Poetry 1.4+ does replace a same-version URL or file build (measured again in this run: 1.8.5 and 2.5.2 restore upstream). The CLI already knows about pre-1.4 lock writers. The forward rewrite warns redirect_poetry_stale_install_risk / pypi_poetry_integrity_unverified from PoetryLockWriter::is_pre_1_4. The unwind direction never checks.

Impact

  • After undoing a patch, the user is told the next install puts upstream back, and they see Poetry say it is "Updating six". Their venv keeps running Socket's build anyway, with no warning in human or --json output (warnings: []). Security isn't reduced, but the CLI's statement is wrong, and so is the user's picture of what's installed.
  • After a vendored unwind on 1.1.15, the installed six-1.16.0.dist-info/direct_url.json still names .socket/vendor/pypi/<uuid>/six-…whl, which the revert deleted.

Repro

A local mock of the patch API grants pkg:pypi/six@1.16.0 with a patched wheel (SOCKET_PATCHED = 1 appended to six.py), the same fixture shape as crates/socket-patch-cli/tests/e2e_vex_build/poetry.rs. Real Poetry, real PyPI, Linux.

cat > pyproject.toml <<'P'
[tool.poetry]
name = "demo-app"
version = "0.1.0"
description = ""
authors = ["x <x@example.com>"]
[tool.poetry.dependencies]
python = ">=3.8"
six = "1.16.0"
P
printf '[virtualenvs]\nin-project = true\n' > poetry.toml
poetry lock && rm -rf .venv && cp poetry.lock /tmp/lock.orig        # Poetry 1.3.2 (or 1.1.15)
socket-patch scan --mode hosted --yes      # or: --mode vendored
poetry install --no-root
poetry run python -c 'import six; print(getattr(six,"SOCKET_PATCHED",0))'   # 1
socket-patch rollback --yes                # or (vendored): socket-patch vendor --revert --yes
#  Note: 1 unwired package keeps its patched bytes in installed trees until the next package-manager install.
cmp /tmp/lock.orig poetry.lock             # identical
poetry install --no-root                   # 1.3.2: "Updating six (1.16.0 http://…/six-1.16.0-py2.py3-none-any.whl -> 1.16.0)"
poetry run python -c 'import six; print(getattr(six,"SOCKET_PATCHED",0))'   # still 1

Remedy that works on both releases: poetry run pip uninstall -y six && poetry install (or recreate the venv). After it, the import shows upstream bytes.

Expected vs actual

  • Expected: on a lock whose writer is pre-1.4, the unwind names a reinstall that actually restores upstream bytes, as pypi_reinstall.rs does for pip, PDM, uv and Pipenv (Fix PyPI rollback reinstall advice (#477) #1308, Fix pip reinstall advisory after unwind (#1953) #1954). docs/testing/poetry-compatibility.md "Installer boundaries" already lists 1.0–1.3 as "Replaces an already-installed same-version package: no", and the forward direction warns about that.
  • Actual: the generic "until the next package-manager install" note on rollback, nothing on vendor --revert, and no warning code in --json.

Versions

Poetry Mode / command Result
1.1.15 (lock 1.1) hosted rollback fail (patched after poetry install, 2/2)
1.1.15 vendored rollback, vendor --revert fail
1.3.2 (lock 2.0, unstamped) hosted rollback fail (2/2)
1.3.2 vendored rollback, vendor --revert fail
1.0.x — not run; the docs table says it doesn't replace either
1.8.5, 2.5.2 hosted rollback, vendored rollback pass (Updating six … -> 1.16.0 restores upstream)

socket-patch: main cfc870f and release v5.1.0 behave the same, so this isn't a regression.

Suspect code

  • crates/socket-patch-cli/src/commands/pypi_reinstall.rs:50 (Tool::of_flavor) and :63 (Tool::of_file) have no Poetry case, so a pre-1.4 poetry.lock falls through to the generic note.
  • crates/socket-patch-core/src/utils/poetry_lock.rs:379 (is_pre_1_4) already makes this decision for the forward warnings, in crates/socket-patch-core/src/patch/redirect/poetry.rs:164 and crates/socket-patch-core/src/vendor/pypi_poetry.rs.

This was measured on Linux only. Poetry's same-version skip is platform-independent, so macOS and Windows should behave the same.


Generated by Claude Code

Activity

  1. added
    bug
    bughunt
    pm:poetry
    on Nov 27, 2026
  2. added a commit that references this issue on Nov 27, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    agent:triagedbugbughuntpm:poetrypriority:p1

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions