Skip to content

Commit 972cb57

Browse files
committed
fix(presets): avoid promising unsatisfiable extension updates
Assisted-by: ChatGPT (model: GPT-5, supervised)
1 parent 853e67d commit 972cb57

2 files changed

Lines changed: 29 additions & 3 deletions

File tree

‎src/specify_cli/presets/_commands.py‎

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -59,8 +59,10 @@ def _warn_unmet_extension_dependencies(manager, manifest) -> None:
5959
extension_id = _escape_markup(dep["id"])
6060
reason = dep["reason"]
6161
# The remediation has to match the reason. `extension add` refuses an
62-
# already-installed extension without --force, so suggesting it for a
63-
# disabled or out-of-date one would hand the user a command that fails.
62+
# already-installed extension without --force, and `extension update`
63+
# only moves forward to the catalog release. A general PEP 440
64+
# constraint may require an exact version, an upper bound, or a
65+
# downgrade, so do not promise that update will satisfy it.
6466
if reason == "missing":
6567
console.print(f" [yellow]{extension_id}[/yellow] is not installed")
6668
remedy = f"specify extension add {extension_id}"
@@ -73,7 +75,10 @@ def _warn_unmet_extension_dependencies(manager, manifest) -> None:
7375
f"{_escape_markup(dep['installed'])} does not satisfy "
7476
f"{_escape_markup(dep['version'])}"
7577
)
76-
remedy = f"specify extension update {extension_id}"
78+
remedy = (
79+
"install a release of "
80+
f"{extension_id} satisfying {_escape_markup(dep['version'])}"
81+
)
7782
console.print(f" Fix with: {remedy}")
7883
console.print()
7984
console.print(

‎tests/test_presets.py‎

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,8 @@
4040
VALID_PRESET_TEMPLATE_TYPES,
4141
)
4242
from specify_cli.extensions import ExtensionRegistry
43+
from specify_cli._console import console
44+
from specify_cli.presets._commands import _warn_unmet_extension_dependencies
4345

4446

4547
# ===== Fixtures =====
@@ -1245,6 +1247,25 @@ def test_unsatisfied_version_constraint_reports_both_versions(
12451247
assert unmet[0]["installed"] == "0.1.0"
12461248
assert unmet[0]["version"] == ">=9.0.0"
12471249

1250+
def test_version_warning_does_not_promise_update_satisfies_constraint(self):
1251+
"""Version remediation must handle constraints update cannot guarantee."""
1252+
manager = MagicMock()
1253+
manager.find_unmet_extension_dependencies.return_value = [
1254+
{
1255+
"id": "speckit-inventory",
1256+
"reason": "version",
1257+
"installed": "3.0.0",
1258+
"version": "<2",
1259+
}
1260+
]
1261+
1262+
with console.capture() as capture:
1263+
_warn_unmet_extension_dependencies(manager, MagicMock())
1264+
1265+
output = strip_ansi(capture.get())
1266+
assert "install a release of speckit-inventory satisfying <2" in output
1267+
assert "specify extension update" not in output
1268+
12481269
def test_optional_dependency_is_never_reported(
12491270
self, project_dir, temp_dir, valid_pack_data
12501271
):

0 commit comments

Comments
 (0)