Hosted rollback and remove refuse every Hatch 1.18 locked environment, because Hatch writes pylock.toml with --no-header
Maintainer antworten meist innerhalb von 1 Tag
Dieses Issue hat noch niemand übernommen.
Bewertung
- Schwierigkeit
- 4/5
- Geschätzter Aufwand
- 3-5 Tage
- Anfängerfreundlichkeit
- 45/100
Rechercherichtung
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.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Beschreibung
[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
- Vorherrschende Sprache
- Rust
- Sterne
- 9
- Forks
- 2
- Ø Merge
- 1 T. 8 Std.
- Gemergte PRs (30 T.)
- 313
Entwicklungsumgebung
- Kein Dockerfile und keine Docker-Compose-Datei
- Keine Pull-Request-Vorlage
- Beitragsleitfaden lesen
Erste Schritte
- Lesen Sie das ganze Issue und danach den Beitragsleitfaden des Projekts.
- Schreiben Sie ins Issue, dass Sie es übernehmen — das erspart doppelte Arbeit.
- Forken Sie das Repository und arbeiten Sie in einem Branch.
- Öffnen Sie einen Pull Request, der die Issue-Nummer nennt.
Mehr aus SocketDev/socket-patch
-
agent:triaged arch-audit bug priority:p2
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 84/100
SocketDev/socket-patch#2306 ·
Maintainer antworten meist innerhalb von 1 Tag
-
agent:triaged arch-audit bug priority:p3
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 88/100
SocketDev/socket-patch#2296 ·
Maintainer antworten meist innerhalb von 1 Tag
-
agent:needs-human agent:triaged ci-janitor priority:p1
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 72/100
SocketDev/socket-patch#2270 · 3 Kommentare ·
Maintainer antworten meist innerhalb von 1 Tag
-
agent:triaged arch-audit bug priority:p1
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 82/100
SocketDev/socket-patch#2259 ·
Maintainer antworten meist innerhalb von 1 Tag
-
agent:triaged arch-audit priority:p3 refactor
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 83/100
SocketDev/socket-patch#1860 ·
Maintainer antworten meist innerhalb von 1 Tag
Alle Issues in SocketDev/socket-patch
Ähnliche Issues
-
Bash init calls `cygpath` unconditionally on Windows, which breaks non-Cygwin shells like `brush`Evtl. vergeben @iliqiliev hat das heute übernommen. Offen
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 72/100
ajeetdsouza/zoxide#1381 ·
Maintainer antworten meist innerhalb von 5 Tagen
-
triage
Schwierigkeit 1/5 1-3 Stunden Anfängerfreundlichkeit 88/100
kornia/kornia-rs#1416 · 1 Kommentar ·
Maintainer antworten meist innerhalb von 2 Tagen
-
enhancement
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 68/100
Maintainer antworten meist innerhalb von 2 Tagen
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 70/100
paritytech/revive#749 ·
Maintainer antworten meist innerhalb von 3 Tagen
-
bug
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 82/100
swc-project/swc-next-issues#1043 ·