Add uv fix support to the Python package updater - #883
Merged
Merged
Conversation
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Advanced Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
Comment |
Jordanh1996
reviewed
Sep 15, 2026
Jordanh1996
reviewed
Sep 15, 2026
Jordanh1996
reviewed
Sep 15, 2026
Jordanh1996
reviewed
Sep 15, 2026
Jordanh1996
requested changes
Sep 15, 2026
Jordanh1996
left a comment
Contributor
There was a problem hiding this comment.
From frogbot side - don't forget to whitelist yarn and uv(and dotnet once its ready)
Jordanh1996
approved these changes
Sep 17, 2026
uv is detected but had no fix implementation: GetCompatiblePackageUpdater had no case for it, so a fix attempt hit the unsupported-technology path. Adds a handleUv method that rewrites the pinned dependency directly in pyproject.toml (wherever it appears - main dependencies, optional extras, or a PEP 735 dependency-groups table) and then runs 'uv lock --upgrade-package' to refresh uv.lock. This mirrors how Renovate fixes uv dependencies today, and avoids needing to know which --group/--optional flag 'uv add' would require, since that information isn't available from the vulnerability evidence. Workspace-owned dependencies aren't targeted: since the handler only ever edits the scanned target's own pyproject.toml, a dependency declared by a workspace member fails safely with the same "impacted package not found" error Pip's handler already returns for an unmatched package, rather than risking editing the wrong file. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
…elds Three issues from review: - The package name was interpolated into the regex without QuoteMeta or a left boundary, so fixing "attrs" also matched inside "cattrs" and silently bumped the wrong package. - FindString + Replace(..., 1) only fixed the first declaration, so a package listed in both [project].dependencies and a [dependency-groups] table was left half-edited, making the subsequent uv lock fail as unsatisfiable. - No rollback of pyproject.toml when uv lock fails, unlike the other package updaters (npm, pnpm, yarn, go) that all restore the original descriptor on a failed lock/install step. Fixes: - Escape the package name with regexp.QuoteMeta and require a left boundary (start of file, or preceded by whitespace/quote/bracket/ comma) before it, so it can't match as a suffix of another name. - Use ReplaceAllString instead of FindString+Replace(..., 1), so every declaration of the same package gets fixed together. - Roll pyproject.toml back to its original content if uv lock fails, matching the existing convention in npm/pnpm/yarn/go's updaters. - Removed Uv's packageInstallationCommand/packageVersionOperator from techutils.go - unused, since handleUv doesn't go through the generic CLI-add path those fields configure. Added regression tests (TestHandleUvSubstringCollisionSafe, TestHandleUvFixesAllDeclarations) and their testdata fixtures, reproducing both bugs from review before the fix. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
orto17
force-pushed
the
feature/uv-fix-support
branch
from
September 17, 2026 08:19
42d870d to
a338c59
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
devbranch.go vet ./....go fmt ./....Stacks on top of jfrog/jfrog-cli-security#880 (Pip/Uv detection ambiguity fix) — uv is now detected correctly, but there was no fix implementation for it: GetCompatiblePackageUpdater had no case for techutils.Uv, so any fix attempt hit the unsupported-technology path.
Adds a handleUv method to PythonPackageUpdater that rewrites the pinned dependency directly in pyproject.toml — wherever it appears (main dependencies, optional extras, or a PEP 735 dependency-groups table) — then runs uv lock --upgrade-package to refresh uv.lock.
Why not uv add
The obvious approach, mirroring Poetry's handler (poetry add pkg==version + poetry update), doesn't generalize: uv add pkg==version requires an explicit --group/--optional flag to target anything outside the main dependency list, and hard-fails with a resolver conflict if you omit it while the package lives in a dependency-groups table. There's no evidence data available (from Xray or the SBOM) telling us which group a dependency came from, so that flag can never be chosen reliably.
Instead this reuses the same mechanism the existing Pip handler already uses (handlePip): a text substitution of the exact pinned line, regardless of which manifest table it's in, followed by a lock refresh. It's also simpler than Poetry's handler — uv add already keeps pyproject.toml and uv.lock in sync in one command, so the equivalent here is one substitution + one scoped lock refresh, no two-step CLI dance.
Verification
Added test fixtures under tests/testdata/projects/package-managers/uv/ (plain project, indirect-dependency, dependency-groups, and a two-package workspace) and four new subtests in TestUpdateDependency:
Indirect dependency → ErrUnsupportedFix, matching pip/poetry/pipenv.
Plain direct dependency → pyjwt==1.7.1 becomes 2.4.0 in pyproject.toml; uv.lock refreshed.
Dependency-groups ([dependency-groups].dev) → same fix succeeds, no --group flag needed, unlike a naive uv add.
Workspace (dependency owned by a member, not the root) → fails safely with "impacted package not found, fix failed", the same error Pip's handler already returns for an unmatched package; root's pyproject.toml is left untouched.
Limitations