From 0885e4de1263d9dfd607966e94e57893f755d2a4 Mon Sep 17 00:00:00 2001 From: xunguangzlj-cloud Date: Sun, 8 Nov 2026 16:04:20 +0800 Subject: [PATCH] fix(presets): render missing preset IDs as literal text Assisted-by: OpenAI Codex (model: GPT-6, autonomous) --- src/specify_cli/presets/command_info.py | 2 +- .../specify_cli/presets/test_command_info.py | 23 +++++++++++++++++++ 2 files changed, 24 insertions(+), 1 deletion(-) diff --git a/src/specify_cli/presets/command_info.py b/src/specify_cli/presets/command_info.py index b6b7b2848f..4aa213ae79 100644 --- a/src/specify_cli/presets/command_info.py +++ b/src/specify_cli/presets/command_info.py @@ -113,7 +113,7 @@ def preset_info( if not pack_info: console.print( - f"[red]Error:[/red] Preset '{preset_id}' not found (not installed and not in catalog)" + f"[red]Error:[/red] Preset '{safe_preset_id}' not found (not installed and not in catalog)" ) raise typer.Exit(1) diff --git a/tests/specify_cli/presets/test_command_info.py b/tests/specify_cli/presets/test_command_info.py index 1379e6e3a1..0667c7281f 100644 --- a/tests/specify_cli/presets/test_command_info.py +++ b/tests/specify_cli/presets/test_command_info.py @@ -124,6 +124,29 @@ def test_info_escapes_catalog_markup(self, project_dir): # Tags are joined into a single line, so assert on the rendered join. assert ", ".join(self.MARKUP_PRESET["tags"]) in output + def test_info_renders_missing_preset_id_literally(self, project_dir): + from unittest.mock import patch + + from typer.testing import CliRunner + + from specify_cli import app + + catalog = seed_catalog(project_dir, []) + preset_id = "[/bold]missing" + with ( + patch.object(Path, "cwd", return_value=project_dir), + patch.object( + PresetCatalog, + "get_active_catalogs", + return_value=default_catalog_entries(catalog), + ), + ): + result = CliRunner().invoke(app, ["preset", "info", preset_id]) + + assert isinstance(result.exception, SystemExit), result.exception + assert result.exit_code == 1 + assert f"Preset '{preset_id}' not found" in strip_ansi(result.output) + class TestPresetInfoInstalledMarkup: """Locally installed preset metadata must render as literal text.