fix(actor): propagate typer.Exit through CLI exception handlers and add missing BDD step
CI / typecheck (pull_request) Failing after 0s
CI / lint (pull_request) Failing after 0s
CI / security (pull_request) Failing after 0s
CI / quality (pull_request) Failing after 0s
CI / unit_tests (pull_request) Failing after 0s
CI / coverage (pull_request) Has been skipped
CI / docker (pull_request) Has been skipped
CI / integration_tests (pull_request) Failing after 0s
CI / build (pull_request) Failing after 0s
CI / helm (pull_request) Failing after 0s
CI / push-validation (pull_request) Failing after 0s
CI / status-check (pull_request) Failing after 0s
CI / typecheck (pull_request) Failing after 0s
CI / lint (pull_request) Failing after 0s
CI / security (pull_request) Failing after 0s
CI / quality (pull_request) Failing after 0s
CI / unit_tests (pull_request) Failing after 0s
CI / coverage (pull_request) Has been skipped
CI / docker (pull_request) Has been skipped
CI / integration_tests (pull_request) Failing after 0s
CI / build (pull_request) Failing after 0s
CI / helm (pull_request) Failing after 0s
CI / push-validation (pull_request) Failing after 0s
CI / status-check (pull_request) Failing after 0s
- actor.py and actor_run.py: broaden `except click.exceptions.Exit` to
`except (click.exceptions.Exit, typer.Exit)` so that typer.Exit(code=N)
raised by _resolve_config_files propagates with the original exit code
instead of being caught by the generic Exception handler and re-raised
as code 3. Fixes Unknown Actor Name Error / Actor App Unknown Name Error
integration tests.
- actor_run_signature_resolve_steps.py + actor_run_signature_security_steps.py:
add typer.Exit to the exception catches around resolve_config_files calls
so Behave scenarios correctly capture the exit code.
- cloud_types_steps.py: add missing @then("it should reject tags with empty key")
step for the AWSResource tags validation scenario.
ISSUES CLOSED: #8607
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)
|
||||
)
|
||||
|
||||
@@ -146,6 +146,13 @@ def step_aws_empty_tag_key(context):
|
||||
context.exc = exc
|
||||
|
||||
|
||||
@then("it should reject tags with empty key")
|
||||
def step_rejects_empty_tag_key(context):
|
||||
"""Assert a ValidationError was raised for a tag with an empty key."""
|
||||
assert context.exc is not None
|
||||
assert isinstance(context.exc, ValidationError)
|
||||
|
||||
|
||||
@when('its region is set to "us-west-2"')
|
||||
def step_aws_region(context):
|
||||
"""Set AWS resource region."""
|
||||
|
||||
@@ -185,12 +185,12 @@ 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)
|
||||
raise typer.Exit(code=2) from exc
|
||||
except Exception as exc: # pragma: no cover
|
||||
except Exception as exc:
|
||||
typer.echo(f"Unexpected error: {exc}", err=True)
|
||||
raise typer.Exit(code=3) from exc
|
||||
|
||||
|
||||
@@ -159,12 +159,12 @@ 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)
|
||||
raise typer.Exit(code=2) from exc
|
||||
except Exception as exc: # pragma: no cover
|
||||
except Exception as exc:
|
||||
typer.echo(f"Unexpected error: {exc}", err=True)
|
||||
raise typer.Exit(code=3) from exc
|
||||
|
||||
|
||||
Reference in New Issue
Block a user