From e5d4f632986600abe43730b8631cb9ead88f7b10 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Mon, 9 Mar 2026 19:18:05 +0000 Subject: [PATCH] fix: wrap _load_catalog_config() calls in catalog_list with try/except - Check SPECKIT_CATALOG_URL first (matching get_active_catalogs() resolution order) - Wrap both _load_catalog_config() calls in try/except ValidationError so a malformed config file cannot crash `specify extension catalog list` after the active catalogs have already been printed successfully Co-authored-by: mnriem <15701806+mnriem@users.noreply.github.com> --- src/specify_cli/__init__.py | 28 +++++++++++++++++++--------- 1 file changed, 19 insertions(+), 9 deletions(-) diff --git a/src/specify_cli/__init__.py b/src/specify_cli/__init__.py index babd1b4f..209632a7 100644 --- a/src/specify_cli/__init__.py +++ b/src/specify_cli/__init__.py @@ -1881,17 +1881,27 @@ def catalog_list(): config_path = project_root / ".specify" / "extension-catalogs.yml" user_config_path = Path.home() / ".specify" / "extension-catalogs.yml" - if config_path.exists() and catalog._load_catalog_config(config_path) is not None: - console.print(f"[dim]Config: {config_path.relative_to(project_root)}[/dim]") - elif os.environ.get("SPECKIT_CATALOG_URL"): + if os.environ.get("SPECKIT_CATALOG_URL"): console.print("[dim]Catalog configured via SPECKIT_CATALOG_URL environment variable.[/dim]") - elif user_config_path.exists() and catalog._load_catalog_config(user_config_path) is not None: - console.print("[dim]Config: ~/.specify/extension-catalogs.yml[/dim]") else: - console.print("[dim]Using built-in default catalog stack.[/dim]") - console.print( - "[dim]Add .specify/extension-catalogs.yml to customize.[/dim]" - ) + try: + proj_loaded = config_path.exists() and catalog._load_catalog_config(config_path) is not None + except ValidationError: + proj_loaded = False + if proj_loaded: + console.print(f"[dim]Config: {config_path.relative_to(project_root)}[/dim]") + else: + try: + user_loaded = user_config_path.exists() and catalog._load_catalog_config(user_config_path) is not None + except ValidationError: + user_loaded = False + if user_loaded: + console.print("[dim]Config: ~/.specify/extension-catalogs.yml[/dim]") + else: + console.print("[dim]Using built-in default catalog stack.[/dim]") + console.print( + "[dim]Add .specify/extension-catalogs.yml to customize.[/dim]" + ) @catalog_app.command("add")