Repository navigation
Description
Problem Statement
A Git-backed publisher can regenerate a Python manifest after updating uv.lock and commit a stale requirements.txt.lock. Connect reads the requirements file named by the manifest, but its contents can differ from the export used to calculate the manifest checksum. Even an unchanged dependency set can expose the mismatch because the export includes a timestamp.
Solution
When a Python write-manifest command uses -r uv.lock --overwrite, refresh the generated requirements file alongside the manifest. The publisher can then commit both outputs together. Preserve requirements files supplied directly by the publisher.
User Stories
- As a Git-backed publisher, I want manifest regeneration to pick up a changed locked dependency so that Connect receives the version I selected.
- As a publisher rerunning the command with an unchanged lockfile, I want the checksum to match the resulting file so that I can commit a consistent pair of outputs.
- As a notebook, Quarto, or Python application author, I want the same overwrite behavior across commands that accept a uv lockfile so that I can use the same publishing workflow.
- As an author who supplies a requirements file directly, I want to retain its exact contents so that regenerating a manifest preserves my input.
- As a publisher who omits
--overwrite, I want the existing manifest overwrite guard so that an accidental rerun preserves my published configuration.
Implementation Decisions
- Treat
uv.lockas the input and its exportedrequirements.txt.lockas generated output. Determine that distinction from how the requirements were obtained. A file namedrequirements.txt.lockcan itself be supplied directly. - Use the same export for the file written to disk and the checksum recorded in the manifest. Apply this contract to every Python
write-manifestcommand that supports a uv lockfile.
Testing Decisions
- Exercise the public
write-manifestCLI in a temporary content directory. Follow the existing parameterized document-command tests that invoke Click and prepare a real uv lockfile offline. - Generate a manifest, change a locked dependency, and regenerate with
--overwrite. Read the requirements file named in the manifest, verify the updated dependency, and compare the MD5 digest of the exact bytes on disk with the manifest entry. A changed dependency makes this regression deterministic without waiting for a timestamp change. - Cover each affected command path. Repeat with an unchanged lockfile and verify checksum consistency. With a directly supplied requirements file, including one named
requirements.txt.lock, verify that its original bytes survive regeneration.
Out of Scope
Changes to deployment commands, Connect server behavior, and the uv export format.
Further Notes
The reporter’s workaround is to remove the generated requirements.txt.lock before rerunning the command. Related publishing guide: posit-dev/connect#48563.
Reported reproduction
Tested with rsconnect-python==1.34.0 through posit-cli==0.3.0. From a fresh directory with uv installed, run:
uv init --bare --python 3.10 --pin-python
uv venv --python 3.10
uv lock
touch app.py
posit connect write-manifest api . -r uv.lock
posit connect write-manifest api . -r uv.lock --overwrite
python3 - <<'PY'
import hashlib
import json
from pathlib import Path
lock = Path('requirements.txt.lock')
manifest = json.loads(Path('manifest.json').read_text())
assert manifest['files'][lock.name]['checksum'] == hashlib.md5(lock.read_bytes()).hexdigest()
PY
Activity