Repository navigation
Fix hosted Hatch ignoring uv sources (#673) - #1706
Mikola Lysenko (mikolalysenko) wants to merge 3 commits into
Conversation
Assisted-by: Claude Code:claude-opus-5-5
When a Hatch environment uses the uv installer, uv resolves a project dependency through the project's [tool.uv.sources] entry instead of the direct reference hosted mode writes. A url or path source then installs the unpatched wheel while the scan reports "redirected", and a git source breaks every install with conflicting URLs. Hosted Hatch now refuses such a pin before writing, as it already does for Hatch's own source tables, and reports redirect_hatch_unsupported. Environment dependencies, index-only sources and the pip installer are unaffected and still rewrite. Fixes #673 Assisted-by: Claude Code:claude-opus-5-5
HATCH_ENV_TYPE_VIRTUAL_UV_PATH switches Hatch to the uv installer with no file setting, so a url or path source still shadowed the hosted pin there. An empty source array is no longer treated as index-only. Refs #673 Assisted-by: Claude Code:claude-opus-5-5
|
BugBot review Generated by Claude Code |
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 84d95a4. Configure here.
|
Ready for review at
Generated by Claude Code |
|
Labeled Ready for review by the burn-down agent.
Generated by Claude Code |
Final review briefWhat it does. When a Hatch environment uses the uv installer, uv resolves a project requirement through Risk: low–medium. The change only adds refusals, so the worst case is a false refusal: the user is pointed to agent mode and never gets an unpatched install. The uv detection reuses the existing Look here
Verified. I read the full diff and the check/apply round logic around it. A target refused in the check pass is skipped in the apply pass, so a partial write can't happen. Changes I made. None. Open questions. None. Auto-merge (squash) is armed: approving sends this PR straight to the merge queue. Generated by Claude Code |
LLM Description written by Claude Code:claude-opus-5-5
Fixes #673
What it fixes
Hosted Hatch scans could report
redirectedand exit 0 while every fresh Hatch environment still installed the unpatched wheel, or failed to install at all. This happened when a Hatch environment uses the uv installer and the project has a[tool.uv.sources]entry for the patched package.Root cause
Hosted mode rewrites the
[project]declaration to a direct reference (six @ <patch url>#sha256=…), but the Hatch planner (crates/socket-patch-core/src/utils/hatch.rs) never read[tool.uv.sources]. Hatch's uv installer runsuv pip install -e ., and uv resolves a project requirement through itstool.uv.sourcesentry instead of the direct reference. A url or path source installs the upstream wheel, and a git source fails with "conflicting URLs".Change
utils/hatch.rs: when any Hatch environment uses the uv installer (installer = "uv"or a non-emptyuv-path, in pyproject or hatch.toml, or a non-emptyHATCH_ENV_TYPE_VIRTUAL_UV_PATH), a patched package with a non-index[tool.uv.sources]entry (url, path, git, workspace, empty array, or a marker array with any non-index member) can no longer be rewritten in[project].dependenciesoroptional-dependencies. The refusal happens before anything is written, like Hatch's own source tables. The hosted lane reports it asredirect_hatch_unsupportedand leaves the dep unconfirmed, so the scan fails closed. Other packages in the same batch still rewrite.dependencies(Hatch passes them to uv as plain strings), index-only sources (the direct URL wins), and the pip installer (pip ignores the table).docs/testing/hatch.md: documents the refusal.Tests
utils::hatch::tests::uv_sources_refuse_project_rewrites_under_the_uv_installer(url / path / git / case-folded name / marker array × project deps / optional deps ×installer/uv-path× pyproject / hatch.toml; plus the allowed shapes, the env-var switch, an empty array and a mixed batch)patch::redirect::hatch_tests::hatch_uv_source_leaves_the_dep_unconfirmed(lane-level: no pyproject write, uuid unconfirmed,redirect_hatch_unsupported)Run locally:
cargo fmt --all -- --check: okcargo clippy --workspace --all-features -- -D warnings: okcargo test -p socket-patch-core --lib hatch: 64 passed. With the fix disabled, both new tests fail.cargo test --workspace --all-features --no-fail-fast: 234 targets ok. 11 tests fail only in this container, and the same tests fail onmainhere. They are chmod-based write-failure tests, which can't fail while the container runs as root (in_process_redirect,repair, 4 core lib tests). The other two aree2e_bun_lockbtests, because the container has bun 1.4.4 instead of CI's version. None touch Hatch.SOCKET_PATCH_HATCH_E2E_VERSION=1.18.1 cargo test -p socket-patch-cli --all-features --test e2e_vex_build hatch:: -- --ignored: 6 passed/code-review high findings not fixed
six = { index = "internal" }with Hatch 1.18.1 + uv and the direct URL won ("pass"), so refusing would be a false refusal. The reviewer's claim is unmeasured.no-sourcesisn't consulted. The refusal fails closed (agent mode still works), so this costs a false refusal, never an unpatched install.envsstill counts as uv. This is the existingrequire_pip_installer_documentsbehavior shared with vendored mode, and it also fails closed.vexalready omits the package after inspecting the env.Note
Medium Risk
Changes hosted Hatch redirect preconditions for uv +
[tool.uv.sources]; behavior is fail-closed with new tests, but misclassification could block valid scans or leave edge cases (workspace-only sources) unhandled.Overview
Fixes #673, where hosted Hatch scans could look successful while uv still installed the unpatched wheel when a Hatch env uses the uv installer and
[tool.uv.sources]overrides the rewritten project pin.The Hatch planner now reads
[tool.uv.sources]when uv is active (installer = "uv",uv-path, orHATCH_ENV_TYPE_VIRTUAL_UV_PATH). For packages with a non-index source (url, path, git, mixed marker arrays, empty arrays), it refuses rewriting[project].dependenciesandoptional-dependenciesbefore any write—same fail-closed pattern as other unsupported Hatch shapes. Hosted redirect leaves the dep unconfirmed, emitsredirect_hatch_unsupported, and does not touchpyproject.toml. Environment dependency tables, index-only sources, the pip installer, and other packages in a batch still rewrite as before.docs/testing/hatch.mddocuments this refusal. Regression coverage spansutils/hatch(matrix of source shapes and mixed batches) and redirect lane testhatch_uv_source_leaves_the_dep_unconfirmed.Reviewed by Cursor Bugbot for commit 84d95a4. Configure here.
Generated by Claude Code