Skip to content

fix(pip-audit): run uv lock before export to handle version bumps#242

Merged
JacobPEvans merged 1 commit intomainfrom
fix/pip-audit-locked
Apr 27, 2026
Merged

fix(pip-audit): run uv lock before export to handle version bumps#242
JacobPEvans merged 1 commit intomainfrom
fix/pip-audit-locked

Conversation

@JacobPEvans
Copy link
Copy Markdown
Owner

Summary

  • Adds uv lock before uv export --locked in run-pip-audit.sh

Why

release-please bumps the package version in pyproject.toml without running uv lock. The existing uv export --locked step then fails with:

error: The lockfile at `uv.lock` needs to be updated, but `--locked` was provided.

uv lock without --upgrade is a no-op when the lock file is already current — it only updates the local package's version metadata. This makes release-please PRs pass pip-audit without manual intervention.

Test Plan

🤖 Generated with Claude Code

release-please bumps the version in pyproject.toml without running
uv lock, leaving the lock file stale. uv export --locked then fails
with "lockfile needs to be updated". Adding uv lock before the export
makes the step a no-op when the lock is current, and fixes it when
only the package version changed (no dependency updates).

(claude)
Copilot AI review requested due to automatic review settings April 27, 2026 12:00
@gemini-code-assist
Copy link
Copy Markdown

Summary of Changes

Hello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request updates the pip-audit execution script to ensure the environment's lockfile is synchronized before attempting to export dependencies. By running uv lock as a proactive step, the process becomes resilient to version metadata changes that occur during automated releases, preventing unnecessary CI failures.

Highlights

  • Lockfile Synchronization: Added a call to uv lock before the export process in the pip-audit script to ensure the lockfile reflects version changes in pyproject.toml.
  • Release Automation: Ensures that automated version bumps by release-please do not cause failures in the pip-audit CI step.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here.


The version bumped in silent night, The lockfile lagged, a sorry sight. But uv lock now clears the way, To keep the audit green all day.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

@JacobPEvans JacobPEvans merged commit b81fee6 into main Apr 27, 2026
4 checks passed
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Updates the central run-pip-audit.sh used by the reusable Python security workflow so pip-audit continues to run successfully when pyproject.toml’s version changes without a corresponding uv.lock update (e.g., release-please PRs).

Changes:

  • Run uv lock before uv export --locked to refresh the lockfile when version metadata drifts.
  • Add inline rationale explaining why the extra lock step is needed.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread scripts/run-pip-audit.sh
Comment on lines +24 to +27
# Sync lock file in case pyproject.toml version was bumped (e.g. by
# release-please) without a corresponding `uv lock` run. This is a
# no-op when the lock file is already up to date.
uv lock
Copy link

Copilot AI Apr 27, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Running uv lock here changes the semantics of this check: previously uv export --locked would fail if the repo’s committed uv.lock was out of date, which helps catch PRs that modify dependency constraints but forget to update/commit the lockfile. With an unconditional uv lock, those PRs will now pass pip-audit by regenerating a lockfile in CI, and pip-audit may end up auditing dependencies that don’t match what’s committed.

Consider either (a) adding a follow-up guard that fails if uv lock produced substantive uv.lock changes that aren’t present in the PR (or at least emits a clear failure message instructing to commit the updated lock), or (b) scoping this behavior to the release-please/version-bump case so dependency drift still fails fast.

Suggested change
# Sync lock file in case pyproject.toml version was bumped (e.g. by
# release-please) without a corresponding `uv lock` run. This is a
# no-op when the lock file is already up to date.
uv lock
# Refresh the lockfile, but fail if this produces uncommitted changes.
# This preserves the original `uv export --locked` semantics: PRs that
# change dependency constraints without committing the updated `uv.lock`
# should fail fast instead of auditing CI-regenerated dependencies.
uv lock
if ! git diff --no-ext-diff --quiet --exit-code -- uv.lock; then
echo "::error file=$dir/uv.lock::uv.lock is out of date with the committed project metadata. Run 'uv lock' locally and commit the updated lockfile."
git --no-pager diff -- uv.lock
exit 1
fi

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants