Hosted rollback and remove refuse every Hatch 1.18 locked environment, because Hatch writes pylock.toml with --no-header
I maintainer di solito rispondono entro 1 giorno
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 4/5
- Tempo stimato
- 3-5 giorni
- Idoneità per principianti
- 45/100
Direzione di ricerca
Start at crates/socket-patch-core/src/patch/redirect/upstream/uv.rs around the reported check near line 428, then trace how Hatch locked environments and their config are identified. Read the hosted restore tests and docs/testing/hatch.md; add coverage for a Hatch 1.18 lock without the uv header, including rollback and remove. Done when those operations restore the lock and paired pyproject.toml as expected while arbitrary headerless uv locks still follow the documented refusal.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
[agent] Found by the scheduled Hatch bug-hunt routine (ledger #314).
Summary
Hatch 1.18.0 and newer write every locked environment's pylock.toml / pylock.<env>.toml with uv pip compile ... --generate-hashes --no-header (hatch/env/lockers/uv.py), so the lock has no # uv pip compile ... header. Since #1614 (8127450, 2026-10-21) the hosted restore refuses any uv-written PEP 751 lock that doesn't record its command line. So on Hatch 1.18.x, socket-patch rollback and socket-patch remove refuse every hosted-wired locked Hatch environment, even with a PyPI sibling package in the lock. They exit 1 with nothing rolled back:
Error: Cannot restore pkg:pypi/[email protected] to its upstream registry entry: pylock.toml: pylock.toml: the lock does not record the `uv pip compile` command line, whose flags may filter which release files it records; restore it from version control instead (`git checkout -- pylock.toml pyproject.toml`)
The same project locked by Hatch 1.17.0, which still writes the header, rolls back byte-exact. Adding that header back to a Hatch 1.18.2 lock by hand also makes the same rollback byte-exact, so the missing header is the only trigger.
Hatch's locker command line isn't unknown. Hatch builds it from the project's own config: --generate-hashes --no-header, the env's python, extras / groups and index-source args. Hatch also re-derives the lock from pyproject whenever the dependency hash changes (#479 / docs/testing/hatch.md). The refusal is meant for an arbitrary uv pip compile --no-header lock whose filter flags really are unknowable, but it also fires on Hatch's own locks.
Impact
On the newest Hatch, hosted rollback and remove don't work for any project that uses Hatch locked environments (locked = true, lock-envs = true, lock-filename). The common path for those projects (scan → install → rollback) ends at an error. It fails closed: nothing is written, the project still installs the patched wheel, and git checkout gets you out. But remove can't take a patch out, and a user without the original in version control has no way back except hand-editing two files.
Repro (Linux, Hatch 1.18.2 with bundled uv 0.13.10, local mock patch API serving a patched six 1.16.0 wheel)
mkdir demo && cd demo && git init -q
cat > pyproject.toml <<'T'
[build-system]
requires = ["hatchling"]
build-backend = "hatchling.build"
[project]
name = "demo"
version = "0.1.0"
dependencies = [
"six==1.16.0",
"toml==0.10.2",
]
[tool.hatch.envs.default]
installer = "uv"
locked = true
T
mkdir -p src/demo && echo 'import six' > src/demo/__init__.py
hatch dep lock # pylock.toml, no header
git add -A && git commit -qm init
socket-patch scan --mode hosted --yes --ecosystems pypi --api-url $MOCK --patch-server-url $MOCK --org test-org --api-token x
# exit 0; rewrites pyproject.toml + pylock.toml; a fresh `hatch run` gets the patched six
socket-patch rollback --yes --api-url $MOCK --patch-server-url $MOCK --org test-org --api-token x
# exit 1, error above; git status still shows both files modified
socket-patch remove pkg:pypi/[email protected] --yes ... # same error, exit 1
Expected
CLI_CONTRACT.md (rollback, hosted restore): for PEP 751 pylock*.toml "+ the paired pyproject.toml", the original entry is restored with hashes re-derived from PyPI's JSON API. This worked for Hatch 1.17 locks, and the Hatch 1.18.1 hosted rollback / remove cell passed on main before #1614. docs/testing/hatch.md doesn't list locked-env rollback as a refusal.
Actual
rollback / remove exit 1 (rollback_failed, "nothing was rolled back: 1 patch failed") for every Hatch 1.18 locked env.
Versions
| socket-patch | Hatch | Lock | rollback / remove |
|---|---|---|---|
main cfc870f |
1.17.0 | pylock.toml (header) |
pass, byte-exact |
main cfc870f |
1.18.1 | pylock.toml (--no-header) |
fail |
main cfc870f |
1.18.2 | pylock.toml (locked = true) |
fail |
main cfc870f |
1.18.2 | pylock.lint.toml (lock-envs = true, env-only dep) |
fail |
main cfc870f |
1.18.2 | same lock with the 1.17-style header added by hand | pass, byte-exact |
| v5.1.0 | 1.17.0 | header | pass |
| v5.1.0 | 1.18.1 / 1.18.2 | --no-header |
fail |
Not a regression since v5.1.0 (the release fails the same way). It is a regression in the 5.1 cycle: the bug-hunt ledger recorded Hatch 1.18.1 hosted rollback / remove passing on main before 2026-10-21. First bad commit by pickaxe: 8127450 "Fix uv restore ignoring lock file filters (#1604, #1613) (#1614)".
Suspect code
crates/socket-patch-core/src/patch/redirect/upstream/uv.rs:428: if pep751 && pip_compiled(...) refuses when uv_header_command finds no header, and doesn't check whether the lock is a Hatch locked environment's lock, whose locker flags can be derived from the Hatch config.
Linux only. Hatch's locker passes the same flags on macOS and Windows, so I expect the same result there.
Generated by Claude Code
- Lingua principale
- Rust
- Stelle
- 9
- Fork
- 2
- Merge medio
- 1g 8h
- PR unite (30g)
- 313
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 arch-audit bug priority:p2
Difficoltà 2/5 1-3 ore Idoneità per principianti 84/100
SocketDev/socket-patch#2306 ·
I maintainer di solito rispondono entro 1 giorno
-
agent:triaged arch-audit bug priority:p3
Difficoltà 2/5 1-3 ore Idoneità per principianti 88/100
SocketDev/socket-patch#2296 ·
I maintainer di solito rispondono entro 1 giorno
-
agent:needs-human agent:triaged ci-janitor priority:p1
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
SocketDev/socket-patch#2270 · 3 commenti ·
I maintainer di solito rispondono entro 1 giorno
-
agent:triaged arch-audit bug priority:p1
Difficoltà 2/5 1-3 ore Idoneità per principianti 82/100
SocketDev/socket-patch#2259 ·
I maintainer di solito rispondono entro 1 giorno
-
agent:triaged arch-audit priority:p3 refactor
Difficoltà 2/5 1-3 ore Idoneità per principianti 83/100
SocketDev/socket-patch#1860 ·
I maintainer di solito rispondono entro 1 giorno
Tutte le issue di SocketDev/socket-patch
Issue simili
-
Bash init calls `cygpath` unconditionally on Windows, which breaks non-Cygwin shells like `brush`Forse già presa @iliqiliev l’ha presa oggi. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
ajeetdsouza/zoxide#1381 ·
I maintainer di solito rispondono entro 5 giorni
-
triage
Difficoltà 1/5 1-3 ore Idoneità per principianti 88/100
kornia/kornia-rs#1416 · 1 commento ·
I maintainer di solito rispondono entro 2 giorni
-
enhancement
Difficoltà 2/5 1-3 ore Idoneità per principianti 68/100
I maintainer di solito rispondono entro 2 giorni
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 70/100
paritytech/revive#749 ·
I maintainer di solito rispondono entro 3 giorni
-
bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 82/100
swc-project/swc-next-issues#1043 ·