Skip to content

Add uv fix support to the Python package updater - #3

Open
orto17 wants to merge 7 commits into
fix/uv-pip-detection-excludefrom
feature/uv-fix-support
Open

orto17 wants to merge 7 commits into
fix/uv-pip-detection-excludefrom
feature/uv-fix-support

Conversation

@orto17

@orto17 orto17 commented Sep 14, 2026

Copy link
Copy Markdown
Owner

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.

  • The pull request is targeting the dev branch.
  • The code has been validated to compile successfully by running go vet ./....
  • The code has been formatted properly using go fmt ./....
  • All static analysis checks passed.
  • All tests have passed. If this feature is not already covered by the tests, new tests have been added.
  • All changes are detailed at the description. if not already covered at JFrog Documentation, new documentation have been added.

Co-authored-by: Claude Sonnet 5 <noreply@anthropic.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
orto17 and others added 3 commits September 17, 2026 11:13
Co-authored-by: Claude Sonnet 5 <noreply@anthropic.com>
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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants