Hosted rollback and remove refuse every Hatch 1.18 locked environment, because Hatch writes pylock.toml with --no-header
维护者通常 1 天内回复
还没有人认领这个 Issue。
评估
调研方向
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.
由索引模型根据 Issue 内容生成。
描述
[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
- 主要语言
- Rust
- 星标
- 9
- 派生
- 2
- 平均合并
- 1 天 8 小时
- 30 天内合并 PR
- 313
环境准备
- 没有 Dockerfile 或 Docker Compose 文件
- 没有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
SocketDev/socket-patch 的其他 Issue
-
agent:triaged arch-audit bug priority:p2
难度 2/5 1-3 小时 新手友好度 84/100
SocketDev/socket-patch#2306 ·
维护者通常 1 天内回复
-
agent:triaged arch-audit bug priority:p3
难度 2/5 1-3 小时 新手友好度 88/100
SocketDev/socket-patch#2296 ·
维护者通常 1 天内回复
-
agent:needs-human agent:triaged ci-janitor priority:p1
难度 2/5 1-3 小时 新手友好度 72/100
SocketDev/socket-patch#2270 · 3 条评论 ·
维护者通常 1 天内回复
-
agent:triaged arch-audit bug priority:p1
难度 2/5 1-3 小时 新手友好度 82/100
SocketDev/socket-patch#2259 ·
维护者通常 1 天内回复
-
agent:triaged arch-audit priority:p3 refactor
难度 2/5 1-3 小时 新手友好度 83/100
SocketDev/socket-patch#1860 ·
维护者通常 1 天内回复
查看 SocketDev/socket-patch 的全部 Issue
相似的 Issue
-
Find/Replace panel: "Previous/Next occurrence" labels overlap and overflow their buttons (French)未关闭
难度 2/5 1-3 小时 新手友好度 63/100
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 78/100
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 62/100
obi1kenobi/cargo-semver-checks#1839 · 3 条评论 ·
维护者通常 1 天内回复
-
Bash init calls `cygpath` unconditionally on Windows, which breaks non-Cygwin shells like `brush`可能已有人在做 @iliqiliev 今天认领。 未关闭
难度 2/5 1-3 小时 新手友好度 72/100
ajeetdsouza/zoxide#1381 ·
维护者通常 5 天内回复
-
triage
难度 1/5 1-3 小时 新手友好度 88/100
kornia/kornia-rs#1416 · 1 条评论 ·
维护者通常 2 天内回复