fix(cli): restore typer.Exit to exception handlers and step catch clauses
CI / helm (pull_request) Successful in 27s
CI / push-validation (pull_request) Successful in 23s
CI / build (pull_request) Successful in 32s
CI / quality (pull_request) Successful in 47s
CI / lint (pull_request) Successful in 57s
CI / typecheck (pull_request) Successful in 1m5s
CI / security (pull_request) Successful in 1m6s
CI / e2e_tests (pull_request) Successful in 3m21s
CI / coverage (pull_request) Successful in 11m0s
CI / unit_tests (pull_request) Failing after 5m56s
CI / docker (pull_request) Has been skipped
CI / integration_tests (pull_request) Failing after 18m11s
CI / status-check (pull_request) Has been cancelled
CI / helm (pull_request) Successful in 27s
CI / push-validation (pull_request) Successful in 23s
CI / build (pull_request) Successful in 32s
CI / quality (pull_request) Successful in 47s
CI / lint (pull_request) Successful in 57s
CI / typecheck (pull_request) Successful in 1m5s
CI / security (pull_request) Successful in 1m6s
CI / e2e_tests (pull_request) Successful in 3m21s
CI / coverage (pull_request) Successful in 11m0s
CI / unit_tests (pull_request) Failing after 5m56s
CI / docker (pull_request) Has been skipped
CI / integration_tests (pull_request) Failing after 18m11s
CI / status-check (pull_request) Has been cancelled
In this project typer.Exit is its own exception class distinct from click.exceptions.Exit. A prior attempt narrowed the catch clauses in actor.py and actor_run.py to click.exceptions.Exit only, and removed typer.Exit from the step-function catch tuples in the resolve and security step files. This caused two categories of CI failures: - Scenarios 38 and 56 (FAIL): _not_found_resolve raises typer.Exit(code=2) inside the CLI command; without the catch in the run() handler it fell through to the generic except Exception branch and was re-raised as exit_code=3, failing the assertion exit_code == 2. - Scenarios 74-100 (ERROR): resolve_config_files raises typer.Exit(code=2) directly; the step functions only caught (SystemExit, click.exceptions.Exit) so the exception escaped uncaught, causing Behave to report ERROR instead of a clean assertion result. Fix: restore `except (click.exceptions.Exit, typer.Exit): raise` in both CLI modules, and add typer.Exit back to every step-function catch tuple that wraps a resolve_config_files call. ISSUES CLOSED: #9972
This commit is contained in:
@@ -165,7 +165,7 @@ def step_resolve_with_no_config_data(context: Any) -> None:
|
||||
try:
|
||||
resolve_config_files("local/empty-actor", [])
|
||||
context.resolve_exit_code = 0
|
||||
except (SystemExit, click.exceptions.Exit) as exc:
|
||||
except (SystemExit, click.exceptions.Exit, typer.Exit) as exc:
|
||||
context.resolve_exit_code = getattr(
|
||||
exc, "exit_code", getattr(exc, "code", 1)
|
||||
)
|
||||
@@ -209,7 +209,7 @@ def step_resolve_unknown_actor_directly(context: Any) -> None:
|
||||
try:
|
||||
resolve_config_files("nonexistent/actor", [])
|
||||
context.resolve_exit_code = 0
|
||||
except (SystemExit, click.exceptions.Exit) as exc:
|
||||
except (SystemExit, click.exceptions.Exit, typer.Exit) as exc:
|
||||
context.resolve_exit_code = getattr(
|
||||
exc, "exit_code", getattr(exc, "code", 1)
|
||||
)
|
||||
@@ -260,7 +260,7 @@ def step_resolve_with_empty_config_blob(context: Any) -> None:
|
||||
try:
|
||||
resolve_config_files("local/empty-blob-actor", [])
|
||||
context.resolve_exit_code = 0
|
||||
except (SystemExit, click.exceptions.Exit) as exc:
|
||||
except (SystemExit, click.exceptions.Exit, typer.Exit) as exc:
|
||||
context.resolve_exit_code = getattr(
|
||||
exc, "exit_code", getattr(exc, "code", 1)
|
||||
)
|
||||
@@ -356,7 +356,7 @@ def step_resolve_with_unserializable_config_blob(context: Any) -> None:
|
||||
try:
|
||||
resolve_config_files("local/bad-blob-actor", [])
|
||||
context.resolve_exit_code = 0
|
||||
except (SystemExit, click.exceptions.Exit) as exc:
|
||||
except (SystemExit, click.exceptions.Exit, typer.Exit) as exc:
|
||||
context.resolve_exit_code = getattr(
|
||||
exc, "exit_code", getattr(exc, "code", 1)
|
||||
)
|
||||
|
||||
@@ -49,7 +49,7 @@ def step_resolve_with_control_character_name(context: Any) -> None:
|
||||
try:
|
||||
resolve_config_files(actor_name, [])
|
||||
context.resolve_exit_code = 0
|
||||
except (SystemExit, click.exceptions.Exit) as exc:
|
||||
except (SystemExit, click.exceptions.Exit, typer.Exit) as exc:
|
||||
context.resolve_exit_code = getattr(
|
||||
exc, "exit_code", getattr(exc, "code", 1)
|
||||
)
|
||||
|
||||
@@ -185,7 +185,7 @@ def run(
|
||||
except UnsafeConfigurationError as exc:
|
||||
typer.echo(f"Error: {exc}", err=True)
|
||||
raise typer.Exit(code=1) from exc
|
||||
except click.exceptions.Exit:
|
||||
except (click.exceptions.Exit, typer.Exit):
|
||||
raise
|
||||
except CleverAgentsError as exc:
|
||||
typer.echo(f"Error: {exc}", err=True)
|
||||
|
||||
@@ -159,7 +159,7 @@ def run(
|
||||
except UnsafeConfigurationError as exc:
|
||||
typer.echo(f"Error: {exc}", err=True)
|
||||
raise typer.Exit(code=1) from exc
|
||||
except click.exceptions.Exit:
|
||||
except (click.exceptions.Exit, typer.Exit):
|
||||
raise
|
||||
except CleverAgentsError as exc:
|
||||
typer.echo(f"Error: {exc}", err=True)
|
||||
|
||||
Reference in New Issue
Block a user