Repository navigation
Fix vendored PyPI routing for a package-less tool lock (#1114) - #2229
Conversation
Refs #1114. Assisted-by: Claude Code:claude-fable-5-2
A Poetry or PDM project whose lock resolves no packages and whose pins live in requirements.txt must vendor through requirements.txt. Today vendor routes to the tool lock and refuses the package. Refs #1114. Assisted-by: Claude Code:claude-fable-5-2
The vendored PyPI router picked a lone poetry.lock or pdm.lock by presence, while the lock inventory reads past one that resolves no packages to requirements.txt. Scan then offered a package that the Poetry or PDM backend refused, with a remedy that writes the same empty lock again. A lone poetry.lock or pdm.lock that parses and resolves no packages no longer governs beside a requirements.txt. Both sides decide that with one predicate. Without a requirements.txt, beside another tool lock, or when the lock does not parse, routing is unchanged. Two router tests used an empty lock file as a stand-in for a real lock. They now hold a package, which is what they meant to test. Refs #1114. Assisted-by: Claude Code:claude-fable-5-2
Review of the previous commit found that dropping the package-less lock before the standalone-lock step changed a result: with a Pipfile in the project, a pylock pinning the package was read as Pipenv's and refused, where it was wired before. The skip now applies only after the standalone locks are decided, so they rank above a tool lock whatever it holds. The package-less test also skips the parse for a lock that holds a [[package]] header, so routing a populated lock costs one substring search, and its docs say which reader it shares with the inventory. Refs #1114. Assisted-by: Claude Code:claude-fable-5-2
|
bugbot run Generated by Claude Code |
PR SummaryLow Risk Overview
Adds CLI contract wording for this case under Reviewed by Cursor Bugbot for commit 438ba5f. Configure here. |
There was a problem hiding this comment.
✅ Bugbot reviewed your changes and found no new issues!
Comment @cursor review or bugbot run to trigger another review on this PR
Reviewed by Cursor Bugbot for commit 438ba5f. Configure here.
|
[agent] PR shepherd: review brief for the approver What it does Risk Look here
Verified
Changes I made Open questions Generated by Claude Code |
Wenxin Jiang (Wenxin-Jiang)
left a comment
There was a problem hiding this comment.
[agent] Reviewed; no major findings.
No PR this run: three routine PRs are open, so the run verified issues and hunted one area on main at cfc870f. L34 is new and filed as #2287: refusals and hosted warnings print the credentials of a URL they quote from a lockfile. 29 of 170 runs over 17 projects print a planted token: Cargo and Yarn classic in vendored mode, Yarn classic, Poetry and a requirements direct reference in hosted mode. Vendor warnings redact in their constructor since #1026; the three other message types do not. #748, #595 and #1112 ran and change nothing a user sees, or only what the contract states. #1114 is fixed in part by #2229. L35 is new and out of charter: the vendored dry run does not predict a refusal made after the download. Assisted-by: Claude Code
LLM Description written by Claude Code:claude-fable-5-2
Refs #1114
Summary
A Poetry or PDM project that declares no dependencies has a lock with no packages, and often installs its pins from
requirements.txt.scan --mode vendoredoffered a package fromrequirements.txt, andvendorthen refused it withpypi_poetry_lock_package_missing(or the PDM twin) and the remedy "runpoetry lockfirst", which writes the same empty lock again.vendornow wiresrequirements.txtin that project and leaves the lock alone.Root cause
Two readers answered "which lock governs" by different rules. The lock inventory reads past a
poetry.lock/pdm.lockthat resolves no packages. The vendored router (detect_pypi_flavor) picked the lock because the file exists.The change
detect_pypi_flavorskips apoetry.lock/pdm.lockwhen all of these hold: it is the only tool lock, it parses, it resolves no packages, and a rootrequirements.txtexists. The project then routes to the requirements wiring, the same as a project with the tool's marker and no lock.lock_inventory::pypi::tool_lock_resolves_nothing, which counts packages with the inventory's own reader.requirements.txt(the tool's refusal names the lock), another tool lock present, a lock that does not parse, and a standalonepylock.toml/ script lock that pins the package (it still outranks the tool lock).CLI_CONTRACT.md: one sentence in thepypi_multiple_lockfilesrow.poetry.lock/pdm.lock. They now hold a[[package]], which is the case they describe. No assertion in them changed.Evidence
mode_migration_pypi::packageless_tool_lock_beside_requirements_vendors_requirements(built binary:vendor, thenvendor --revert)errorCode: pypi_poetry_lock_package_missingvendor::pypi::tests::packageless_tool_lock_beside_requirements_routes_to_requirements(router and inventory agree, Poetry and PDM)vendor::pypi::tests::packageless_tool_lock_governs_without_a_requirements_fallback(the unchanged cases)CI on the head commit (
438ba5f): all 89 checks pass, includingci-okandclippy. Bugbot found no issues.Run locally:
cargo test -p socket-patch-core --lib: 8531 passed on the fix commit; thevendor::tests (3199) re-run on the final commit.cargo test -p socket-patch-clisuitesmode_migration_pypi(84),e2e_vendor_pypi_build(34, 7 ignored),in_process_vendor_pypi_takeover(9), all passed;scan_requirements_lock_only,scan_vendor_requirements_unwired,vendor_eject_fresh_checkout,e2e_vex_vendor,in_process_python_envs,vendor_ledger_schema_e2eandvendor_revert_tamper_e2epassed on the fix commit.cargo clippy --locked --workspace --all-features -- -D warnings(the CI command): clean. With--all-targetsclippy reports 68 findings in test code onmain; none are in a file this PR touches.Review findings (
/code-review high)Fixed:
Pipfile+pylock.tomlproject refuse withpypi_pipenv_pylock_unsupported. The skip now applies after that step; covered by the "beside a pylock" case.[[package]]header is now answered by a substring search.Not fixed, with the reason:
scan --mode hostedover this project keeps it vendored (redirect_takeover_kept_vendored, exit 0, still patched). A direct hosted scan of the same project is refused the same way onmain. Lock inventory and the vendored PyPI router disagree on which lock governs when poetry.lock or pdm.lock has no packages #1114 lists hosted mode as out of scope.poetry add, the lock governs by presence again, and a re-run ofvendorrefuses a package that onlyrequirements.txtholds. This is howmaintreats every populated tool lock beside arequirements.txt, and before this PR the same project failed that way on every run. Fixing it means routing by which file resolves the package, which is a larger change.vexshare, so changing it here would split them.vexdiagnostic.vexprints "packageis not an array of [[package]] tables" for Poetry'spackage = []. It is onmainalready and does not change the document.Left on #1114
https://claude.ai/code/session_011f9aeTAXUPdQSke7V7yAPS
Generated by Claude Code