Skip to content

Hosted scan in a Pipenv project whose requirements.txt pins the package through an -r include rewires only Pipfile.lock, then reports success while vex and rollback refuse the contested lock it just created #567

Closed

Description

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

Summary

Take a Pipenv project that also has a split requirements.txt, a common layout in projects that export for Heroku or Docker or are moving off pip: requirements.txt holds only -r req/base.txt, and req/base.txt pins six==1.16.0. scan --mode hosted rewires the Pipfile.lock entry (both categories) to the Socket-hosted wheel. It leaves req/base.txt untouched, because the hosted requirements rewriter only reads the root requirements.txt (redirect_requirements_entry_not_found, warning only in redirect.warnings). The run reports status: success and exits 0.

Every other command then reads the whole in-root include tree and finds the two locks contesting the patch:

  • vex drops the reference with patched_ref_unattributable ("Pipfile.lock: pkg:pypi/six@1.16.0 is wired to Socket patch …, but req/base.txt resolves the same version from elsewhere"), and exits 2 with nothing attested.
  • rollback refuses the whole project, status: error, exit 1: "Pipfile.lock wire(s) Socket-hosted patches that cannot be attributed to one package version … reconcile the lockfiles (re-run socket-patch scan --mode hosted) or restore them from version control".
  • Re-running scan --mode hosted, the remedy both messages name, exits 0 with success and changes nothing. The state stays wedged.

So socket-patch builds a state it calls unmanageable, and it can't undo that state itself. The only way out is git checkout -- Pipfile.lock.

Control: the same pin written straight into the root requirements.txt gets both files rewired. Then pipenv sync, pipenv install --deploy and pip install -r requirements.txt all get the patched wheel, and vex attests not_affected.

Impact

  • pipenv sync / install --deploy install the patched six, but pip install -r requirements.txt from the same checkout installs unpatched six. Nothing in the human or top-level JSON output says so (the only signal is a redirect.warnings[] entry).
  • vex can never attest the patch in this project, so CI gating on VEX fails for a project that pipenv sync actually patches.
  • rollback / unpatching is impossible without version control. The refusal points at a scan re-run that does nothing.

Repro (Linux, main d63ae5f, local mock of the patch API serving a patched six-1.16.0 wheel)

SP=/path/to/target/release/socket-patch
export SOCKET_PATCH_SERVER_URL=$MOCK
API="--api-url $MOCK --api-token fake --org test-org"
mkdir -p proj/req && cd proj
cat > Pipfile <<'EOF'
[[source]]
url = "https://pypi.org/simple"
verify_ssl = true
name = "pypi"

[packages]
six = "==1.16.0"

[dev-packages]
six = "==1.16.0"
EOF
pipenv lock
printf -- '-r req/base.txt\n' > requirements.txt
printf 'six==1.16.0\nidna==3.7\n' > req/base.txt

$SP scan --mode hosted --yes --json $API   # exit 0, status success, redirected 1, rewrittenFiles ["Pipfile.lock"]
                                            # redirect.warnings: redirect_requirements_entry_not_found
grep six req/base.txt                       # six==1.16.0 (unchanged)
$SP vex --product pkg:pypi/app@0.1.0 -O vex.json $API   # exit 2, patched_ref_unattributable, nothing attested
$SP rollback --json $API                    # exit 1, status error, "cannot be attributed to one package version"
$SP scan --mode hosted --yes --json $API    # exit 0, success, nothing changes; rollback still refuses
PIPENV_VENV_IN_PROJECT=1 pipenv sync        # .venv six: PATCHED
python -m venv pv && pv/bin/pip install -r requirements.txt   # pv six: UNPATCHED

Expected vs actual

  • Expected: CLI_CONTRACT.md (pypi wiring row, line 368) lists the PyPI wiring as "requirements.txt + its in-root -r includes", and line 853 lists the hosted unwind coverage as "requirements.txt (+ in-root -r includes)". The "Contested locks" rule (line 379) treats a lock pair that disagrees as unmanageable. A hosted scan shouldn't produce such a pair and then call it success. Either it rewires the included pin too (as it does for a root pin), or it refuses / skips the Pipfile.lock rewire with a top-level warning and a non-success status. Whatever it wrote, rollback should be able to undo.
  • Actual: scan rewires one side of the pair and reports success. vex exits 2 and rollback exits 1 on the state scan just made, and the suggested rescan doesn't reconcile it.

OS × version (Linux; each cell run from a fresh directory)

Pipenv on PATH (lock written by) main d63ae5f 8eec03a (parent, before the #412 include walk)
none (2026.8.0 lock) fail (3/3) fail (1/1)
2018.11.26 fail (1/1) not run
2023.12.1 fail (1/1); pip install -r unpatched not run
root-pin control (2023.12.1 / 2026.8.0) pass: both files rewired, sync / --deploy patched, vex not_affected n/a

macOS / Windows: not probed (see ledger #313; the probe-branch cleanup is still blocked). The logic is path-only and not OS-specific.

First bad: not a regression from #530 / d63ae5f, because the parent commit 8eec03a behaves the same. v4.0.0 doesn't hosted-redirect this lock-only shape at all (no Pipfile.lock rewrite), so it can't be compared.

Suspect code

  • crates/socket-patch-core/src/patch/redirect/requirements.rs:187: rewrite reads only files.get("requirements.txt"), so included files are never rewired in hosted mode.
  • crates/socket-patch-core/src/vendor/lock_inventory/pypi.rs:683-704: the lock inventory walks the in-root -r include tree (requirements_includes). That's the view vex / rollback use to declare the contest.
  • The hosted scan has no post-write contest check, so it reports success for a wiring that its own vex / rollback reject.

Related, but different: #410 (rollback refuses an all-hosted requirements.txt), #333 (Pipfile + requirements.txt live-lock conflict, fixed), #412 (lock-only discovery of include pins, fixed by #530).


Backlog review — 2026-10-08

Priority: P1 → P2. Competing Pipenv/include requirements prevent VEX and rollback; no successful false attestation is established.

Activity

  1. added
    bug
    bughunt
    pm:pipenv
    on Oct 2, 2026
  2. mikolalysenko commented on Oct 2, 2026

    @mikolalysenko
    CollaboratorAuthor

    [agent] Triaged: priority:p1 (Pipenv). No duplicate or fix PR found. Related to #410 (hosted requirements.txt handling), but that one has a different cause.


    Generated by Claude Code

  3. mikolalysenko commented on Oct 8, 2026

    @mikolalysenko
    CollaboratorAuthor

    [agent] The uv lane of the same defect, from the uv bug-hunt routine (ledger #310). It still reproduces on main 4657813 after #1091, and also on 3b4ac84 (before #1091). This isn't Pipenv-specific: any governing lock next to a requirements tree whose pin lives only in an include hits it.

    printf '[project]\nname = "app"\nversion = "0.1.0"\nrequires-python = ">=3.9"\ndependencies = ["six==1.16.0", "attrs==23.2.0"]\n' > pyproject.toml
    uv lock && uv sync
    uv export --no-hashes --no-emit-project -o base.txt
    printf -- '-r base.txt\n' > requirements.txt
    git add -A && git commit -qm init
    socket-patch scan --mode hosted --dry-run --json   # exit 0, success, no contest warning
    socket-patch scan --mode hosted --yes --json       # exit 0, success; M pyproject.toml, M uv.lock; base.txt untouched
    socket-patch rollback --yes                        # exit 1 hosted_wiring_contested ("base.txt resolves the same version from elsewhere")
    socket-patch remove pkg:pypi/six@1.16.0 --yes      # exit 1 hosted_wiring_contested
    socket-patch scan --mode hosted --yes              # the suggested remedy: exit 0, base.txt still untouched
    socket-patch rollback --yes                        # still exit 1; only `git checkout` gets out
    uv pip install -r requirements.txt                 # unpatched six
    uv Linux
    0.5.31 reproduces (scan 0, rollback / remove / rollback --dry-run 1, vex 2)
    0.12.23 reproduces (same)

    Control: with six==1.16.0 in the root requirements.txt (plus a duplicate pin in an include), hosted rewrites the root line, and pip, uv, vex and a byte-identical rollback all pass. So the failure is specific to pins that live only in an include.

    The vendored side of the uv lane is milder. Vendored scan exits 0 without the #1044 pypi_multiple_lockfiles warning, because the #612 probe reads only the root requirements.txt and not its includes. But vendor --check exits 1, vex refuses, and vendor --revert is byte-identical.


    Generated by Claude Code

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:pipenvpriority:p2

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions