From 7d5c7a11140e26867194be609e2fe0f59aa2fb09 Mon Sep 17 00:00:00 2001 From: Jeffrey Phillips Freeman Date: Sun, 5 Apr 2026 06:55:19 +0000 Subject: [PATCH] fix(error-handling): handle FileNotFoundError in robot.helper_actor_config Wrap ActorConfiguration.from_file() in a try...except FileNotFoundError block in robot/helper_actor_config.py. When the config file path does not exist, print a user-friendly error message to sys.stderr and exit with code 1 instead of crashing with an unhandled exception and raw traceback. Also adds a Robot Framework test case 'Missing Config File Exits With Non-Zero Code And Stderr Message' to robot/actor_configuration.robot to cover the new error path. ISSUES CLOSED: #2829 --- robot/actor_configuration.robot | 6 ++++++ robot/helper_actor_config.py | 6 +++++- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/robot/actor_configuration.robot b/robot/actor_configuration.robot index 8fa6b50bf..c35096af2 100644 --- a/robot/actor_configuration.robot +++ b/robot/actor_configuration.robot @@ -40,3 +40,9 @@ V2 Actor Config Produces Provider And Graph Descriptor List Should Contain Value ${payload['graph_keys']} agents List Should Contain Value ${payload['graph_keys']} routes Should Be Equal As Numbers ${payload['options']['temperature']} 0.5 + +Missing Config File Exits With Non-Zero Code And Stderr Message + ${missing}= Set Variable ${OUTPUT DIR}/does_not_exist_actor.yaml + ${result}= Run Process ${PYTHON} robot/helper_actor_config.py ${missing} + Should Not Be Equal As Integers ${result.rc} 0 + Should Contain ${result.stderr} Error: Config file not found at '${missing}' diff --git a/robot/helper_actor_config.py b/robot/helper_actor_config.py index 3531c0e93..ed54dd24d 100644 --- a/robot/helper_actor_config.py +++ b/robot/helper_actor_config.py @@ -12,7 +12,11 @@ def main() -> None: raise SystemExit("config path required") config_path = Path(sys.argv[1]) - config = ActorConfiguration.from_file(path=config_path) + try: + config = ActorConfiguration.from_file(path=config_path) + except FileNotFoundError: + print(f"Error: Config file not found at '{config_path}'", file=sys.stderr) + sys.exit(1) payload = { "provider": config.provider, "model": config.model,