fix(workflows): guard list against corrupted registry entries, re-raise typer.Exit in catalog install

workflow list now skips non-dict registry entries with a warning instead
of crashing, matching update/enable/disable. The broad except in
_install_workflow_from_catalog no longer swallows typer.Exit, so precise
errors like the non-HTTPS redirect message are not duplicated.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This commit is contained in:
marcelsafin
2026-07-09 01:58:39 +02:00
parent cc8143ea73
commit 59a791b940
2 changed files with 32 additions and 0 deletions

View File

@@ -582,6 +582,9 @@ def workflow_list():
console.print("\n[bold cyan]Installed Workflows:[/bold cyan]\n")
for wf_id, wf_data in installed.items():
if not isinstance(wf_data, dict):
console.print(f" [yellow]Warning:[/yellow] Skipping corrupted registry entry '{wf_id}'.\n")
continue
marker = "" if wf_data.get("enabled", True) else " [red]\\[disabled][/red]"
console.print(f" [bold]{wf_data.get('name', wf_id)}[/bold] ({wf_id}) v{wf_data.get('version', '?')}{marker}")
desc = wf_data.get("description", "")
@@ -866,6 +869,8 @@ def _install_workflow_from_catalog(
)
raise typer.Exit(1)
workflow_file.write_bytes(response.read())
except typer.Exit:
raise
except Exception as exc:
if workflow_dir.exists():
import shutil

View File

@@ -7490,6 +7490,33 @@ steps:
assert result.exit_code == 0, result.output
assert "corrupted" in result.output
def test_list_skips_corrupted_registry_entry(self, project_dir, monkeypatch):
import json
from typer.testing import CliRunner
from specify_cli import app
from specify_cli.workflows.catalog import WorkflowRegistry
monkeypatch.chdir(project_dir)
registry_path = WorkflowRegistry(project_dir).registry_path
registry_path.parent.mkdir(parents=True, exist_ok=True)
registry_path.write_text(
json.dumps(
{
"schema_version": "1.0",
"workflows": {
"broken": "not-a-dict",
"ok": {"name": "OK Workflow", "version": "1.0.0"},
},
}
),
encoding="utf-8",
)
runner = CliRunner()
result = runner.invoke(app, ["workflow", "list"])
assert result.exit_code == 0, result.output
assert "corrupted" in result.output
assert "OK Workflow" in result.output
def test_enable_disable_corrupted_registry_entry_errors(self, project_dir, monkeypatch):
import json
from typer.testing import CliRunner