fix(error-handling): handle parsing errors in robot.helper_actor_config #2835

Open
opened 2026-04-04 20:46:06 +00:00 by freemo · 0 comments
Owner

Metadata

  • Branch: fix/error-handling-helper-actor-config-parsing
  • Commit Message: fix(error-handling): catch and report config parsing errors in helper_actor_config
  • Milestone: v3.6.0
  • Parent Epic: #362

Background

The script at robot/helper_actor_config.py does not handle exceptions that can occur during the parsing of the actor configuration file. If the file is not valid YAML or does not match the expected schema, the ActorConfiguration.from_file method will raise an unhandled exception, causing the script to crash with a raw traceback rather than a user-friendly error message.

Location

  • File: robot/helper_actor_config.py
  • Function: main
  • Lines: 14–15

Evidence

def main() -> None:
    if len(sys.argv) < 2:
        raise SystemExit("config path required")

    config_path = Path(sys.argv[1])
    config = ActorConfiguration.from_file(path=config_path)  # ← unguarded
    # ...

Expected Behavior

The script should catch exceptions that occur during configuration parsing, print a user-friendly error message to stderr, and exit gracefully with a non-zero exit code.

Actual Behavior

The script crashes with an unhandled exception when the config file is malformed, missing, or fails schema validation.

Suggested Fix

def main() -> None:
    if len(sys.argv) < 2:
        raise SystemExit("config path required")

    config_path = Path(sys.argv[1])
    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)
    except Exception as e:
        print(f"Error: Failed to parse config file at '{config_path}': {e}", file=sys.stderr)
        sys.exit(1)
    # ...

Subtasks

  • Add try/except FileNotFoundError guard around ActorConfiguration.from_file call in main
  • Add general except Exception guard to catch YAML parse errors and schema validation failures
  • Print user-friendly error messages to sys.stderr and call sys.exit(1) on failure
  • Write BDD unit tests (Behave/Gherkin) covering: file-not-found, malformed YAML, and schema validation failure scenarios
  • Ensure all new code is fully statically typed and passes nox -e typecheck
  • Verify nox -e coverage_report remains ≥ 97%

Definition of Done

  • robot/helper_actor_config.py catches FileNotFoundError and prints a clear error to stderr
  • robot/helper_actor_config.py catches general parsing/schema exceptions and prints a clear error to stderr
  • BDD unit tests exist for all error paths (file not found, malformed YAML, schema error)
  • All code is fully statically typed with no # type: ignore suppressions
  • All nox stages pass
  • Coverage >= 97%

Automated by CleverAgents Bot
Supervisor: Unknown | Agent: ca-new-issue-creator

## Metadata - **Branch**: `fix/error-handling-helper-actor-config-parsing` - **Commit Message**: `fix(error-handling): catch and report config parsing errors in helper_actor_config` - **Milestone**: v3.6.0 - **Parent Epic**: #362 ## Background The script at `robot/helper_actor_config.py` does not handle exceptions that can occur during the parsing of the actor configuration file. If the file is not valid YAML or does not match the expected schema, the `ActorConfiguration.from_file` method will raise an unhandled exception, causing the script to crash with a raw traceback rather than a user-friendly error message. ### Location - **File**: `robot/helper_actor_config.py` - **Function**: `main` - **Lines**: 14–15 ### Evidence ```python def main() -> None: if len(sys.argv) < 2: raise SystemExit("config path required") config_path = Path(sys.argv[1]) config = ActorConfiguration.from_file(path=config_path) # ← unguarded # ... ``` ### Expected Behavior The script should catch exceptions that occur during configuration parsing, print a user-friendly error message to `stderr`, and exit gracefully with a non-zero exit code. ### Actual Behavior The script crashes with an unhandled exception when the config file is malformed, missing, or fails schema validation. ### Suggested Fix ```python def main() -> None: if len(sys.argv) < 2: raise SystemExit("config path required") config_path = Path(sys.argv[1]) 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) except Exception as e: print(f"Error: Failed to parse config file at '{config_path}': {e}", file=sys.stderr) sys.exit(1) # ... ``` ## Subtasks - [ ] Add `try/except FileNotFoundError` guard around `ActorConfiguration.from_file` call in `main` - [ ] Add general `except Exception` guard to catch YAML parse errors and schema validation failures - [ ] Print user-friendly error messages to `sys.stderr` and call `sys.exit(1)` on failure - [ ] Write BDD unit tests (Behave/Gherkin) covering: file-not-found, malformed YAML, and schema validation failure scenarios - [ ] Ensure all new code is fully statically typed and passes `nox -e typecheck` - [ ] Verify `nox -e coverage_report` remains ≥ 97% ## Definition of Done - [ ] `robot/helper_actor_config.py` catches `FileNotFoundError` and prints a clear error to `stderr` - [ ] `robot/helper_actor_config.py` catches general parsing/schema exceptions and prints a clear error to `stderr` - [ ] BDD unit tests exist for all error paths (file not found, malformed YAML, schema error) - [ ] All code is fully statically typed with no `# type: ignore` suppressions - [ ] All nox stages pass - [ ] Coverage >= 97% --- **Automated by CleverAgents Bot** Supervisor: Unknown | Agent: ca-new-issue-creator
freemo added this to the v3.6.0 milestone 2026-04-04 20:46:10 +00:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Blocks
#362 Epic: Security & Safety Hardening
cleveragents/cleveragents-core
Reference
cleveragents/cleveragents-core#2835
No description provided.