fix(cli): derive uipath pin in new scaffold from installed version - #1869
Conversation
There was a problem hiding this comment.
Pull request overview
Updates uipath new to derive scaffolded dependency pins from the installed UiPath version.
Changes:
- Adds version-aware dependency generation with fallback handling.
- Adds tests for version derivation, prereleases, fallback behavior, and scaffold output.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Summary |
|---|---|
packages/uipath/tests/cli/test_new.py |
Tests dynamic dependency pin generation and scaffolding behavior. |
packages/uipath/src/uipath/_cli/cli_new.py |
Generates version-aware dependency pins. Critical: combine the importlib.metadata imports to resolve Ruff I001. |
Suppressed comments (1)
packages/uipath/src/uipath/_cli/cli_new.py:53
- This parser only accepts a bare numeric
major.minorprefix, so a valid PEP 440 distribution version with an epoch (for example1!2.14.0) or avprefix reaches this branch and emits the stale 2.10 range even though metadata was found. That can reintroduce the downgrade this change is meant to prevent; parse a normalized PEP 440 version (or fail rather than using the old fallback) for present distributions.
match = re.match(r"^(\d+)\.(\d+)", installed)
if match is None:
console.warning(
f"Could not parse installed 'uipath' version '{installed}'; "
f"falling back to '{_FALLBACK_UIPATH_DEPENDENCY_SPEC}'."
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
5178f19 to
7489596
Compare
a59f550 to
958e327
Compare
958e327 to
85ea80c
Compare
🚨 Heads up:
|
Manual end-to-end verification (local build 2.14.9, commit 85ea80c; hint since reverted to
|
| description = "..." | ||
| authors = [{ name = "Your Name", email = "you@example.com" }] | ||
| requires-python = ">=3.11" | ||
| dependencies = ["uipath>=2.0", "uipath-langchain>=2.0"] |
There was a problem hiding this comment.
Just a documentation inconsistency that was referencing an invalid uipath-langchain version.
uipath new wrote a hard-coded "uipath>=2.10.0, <2.11.0" range, so uv sync downgraded freshly scaffolded projects to 2.10.x on machines running 2.14.x. The pin is now built from the installed distribution's major.minor via _get_safe_version() (same >=X.Y.0, <X.(Y+1).0 shape). When metadata is unavailable it falls back to a range generated from FALLBACK_UIPATH_MINOR, with a warning; a test asserts the fallback admits the installed release so the literal cannot rot silently again. Also: write a GUID id into the scaffolded uipath.json (mirrors init's backfill, silences the 'id' field not present warning), declare packaging as a dev dependency, and fix the impossible uipath-langchain>=2.0 pin in docs/core/agents.md. Bumps uipath to 2.14.9 per repo convention (2.14.8 was taken by #1870). Refs UV-16117 Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
85ea80c to
141d107
Compare
|
#1869 made `uipath new` derive its `uipath>=X.Y.0, <X.(Y+1).0` pin from the installed distribution, with a constant fallback and a CI guard that fails when the fallback lags the release. With that guard in place the runtime detection is redundant: for every shipped wheel the constant already equals the installed minor. Drop the detection and keep the constant, renamed UIPATH_SCAFFOLD_MINOR. The guard test now checks strict equality with the installed minor so a minor bump fails CI in both directions and prompts a review of the whole scaffold (pin, template, hints), not just a mechanical bump. Scaffold output is unchanged. Bump 2.14.9 -> 2.14.10. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
#1869 made `uipath new` derive its `uipath>=X.Y.0, <X.(Y+1).0` pin from the installed distribution, with a constant fallback and a CI guard that fails when the fallback lags the release. With that guard in place the runtime detection is redundant: for every shipped wheel the constant already equals the installed minor. Drop the detection and keep the constant, renamed UIPATH_SCAFFOLD_MINOR. The guard test now checks strict equality with the installed minor so a minor bump fails CI in both directions and prompts a review of the whole scaffold (pin, template, hints), not just a mechanical bump. Scaffold output is unchanged. Bump 2.14.9 -> 2.14.10. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
#1869 made `uipath new` derive its `uipath>=X.Y.0, <X.(Y+1).0` pin from the installed distribution, with a constant fallback and a CI guard that fails when the fallback lags the release. With that guard in place the runtime detection is redundant: for every shipped wheel the constant already equals the installed minor. Drop the detection and keep the constant, renamed UIPATH_SCAFFOLD_MINOR. The guard test now checks strict equality with the installed minor so a minor bump fails CI in both directions and prompts a review of the whole scaffold (pin, template, hints), not just a mechanical bump. Scaffold output is unchanged. Bump 2.14.9 -> 2.14.10. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
`uipath new` hard-coded `uipath-langchain[bedrock,vertex]>=0.10.0, <0.11.0` in the generated pyproject.toml, so `uv sync` right after scaffolding downgraded the project to a stale release. The pin now comes from a single reviewed constant, UIPATH_LANGCHAIN_SCAFFOLD_MINOR, guarded by a test that fails on every minor bump so the scaffold (pin, template, hints) is reviewed alongside the release. Mirrors UiPath/uipath-python#1869 and #1874. Also recommends `uv sync` before `uipath init` in the post-scaffold hints, since `uipath init` imports the template's Bedrock/Vertex chat models and fails without the extras installed. Refs UV-16117 Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
`uipath new` hard-coded `uipath-langchain[bedrock,vertex]>=0.10.0, <0.11.0` in the generated pyproject.toml, so `uv sync` right after scaffolding downgraded the project to a stale release. The pin now comes from a single reviewed constant, UIPATH_LANGCHAIN_SCAFFOLD_MINOR, guarded by a test that fails on every minor bump so the scaffold (pin, template, hints) is reviewed alongside the release. Mirrors UiPath/uipath-python#1869 and #1874. Also recommends `uv sync` before `uipath init` in the post-scaffold hints, since `uipath init` imports the template's Bedrock/Vertex chat models and fails without the extras installed. Refs UV-16117 Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>



uipath newscaffolded apyproject.tomlwith a hard-codeduipath>=2.10.0, <2.11.0dependency that hadn't been bumped since 2.10, so the very next documented step (uv sync) downgraded the project's venv to 2.10.x on machines running 2.14.x (UiPath Jira UV-16117, Issue 1).The fix:
generate_pyproject()now derives the pin from the installed distribution (via the existing_get_safe_version()), keeping the same>=X.Y.0, <X.(Y+1).0shape — pre-release/local suffixes are stripped — so uv resolution behavior is unchanged and only the numbers move. For every normal install (pip/uv/uv tool install) this is the path that runs.The fallback: only when package metadata is unavailable (
_get_safe_version()returns"unknown", e.g. a source checkout run without installing) does it fall back to a literal range generated from a single constant,FALLBACK_UIPATH_MINOR = "2.14", and print a warning.test_fallback_pin_admits_installed_uipathruns against the real installed package in CI and asserts the fallback admits the current release, so a future release PR that forgets to bump the constant fails CI instead of silently rotting. A second regression guard asserts the pin actually written byuipath newcontains the installeduipathversion.Also in the scaffold path: the
Initialize projecthint's stray leading space is gone (it staysuipath init— with the pin derived from the running install, no sync step is needed beforeinit).uipath.jsonnow includes a GUIDid(using the sameresolve_existing_project_id(...) or uuid4()expressioninituses for backfill), sonewno longer emits'id' field not present in uipath.jsonright after creating the file.packagingis declared as a dev dependency (the tests import it; previously only transitive via pytest), anddocs/core/agents.mdno longer showsuipath-langchain>=2.0— that package is 0.x, so the spec resolved to nothing.Package version bumped 2.14.8 → 2.14.9 per repo convention (every PR touching
packages/uipathbumps the patch version; 2.14.8 was released by #1870 while this PR was open).Follow-up (separate repos): the plugin CLIs (
uipath-langchain,uipath-llamaindex,uipath-openai-agents) have the same stale-pin pattern; each should derive from its own installed version with its own minor as fallback and the same guard test.🤖 Generated with Claude Code