BUG-HUNT: [error-handling] Catch-and-ignore pattern in list_personas #2406

Open
opened 2026-04-03 17:35:01 +00:00 by freemo · 1 comment
Owner

Metadata

  • Branch: fix/v3.6.0-list-personas-catch-and-ignore
  • Commit Message: fix(persona): surface invalid persona file errors to the user instead of silently ignoring them
  • Milestone: v3.6.0
  • Parent Epic: #868

Background and context

The PersonaRegistry.list_personas method in src/cleveragents/tui/persona/registry.py (lines 112–113) catches pydantic.ValidationError and yaml.YAMLError exceptions, logs a warning, and silently continues. This violates the project's fail-fast / no-error-suppression architectural principle (CONTRIBUTING.md §Error and Exception Handling): exceptions must only be caught when there is a meaningful recovery path, and must never be caught merely to be logged.

When a user creates a persona file with a YAML syntax error or a Pydantic validation error, the persona is silently dropped from the list. The user receives no in-app feedback and must know to inspect the log file to discover the problem.

Current behavior (for bugs)

Invalid persona files are silently ignored. A WARNING is emitted to the log file via _logger.warning(...), but no feedback is surfaced in the TUI. The user sees a shorter persona list with no explanation.

# src/cleveragents/tui/persona/registry.py  lines 112-113
except (yaml.YAMLError, ValidationError) as exc:
    _logger.warning("Skipping invalid persona file %s: %s", file, exc)

Expected behavior

The application must surface invalid-persona-file errors to the user through the TUI. Acceptable approaches include:

  1. Collecting all parse/validation failures and exposing them via a "health check" or "status" view in the persona management UI.
  2. Raising a custom, typed exception (e.g., InvalidPersonaFileError) that propagates to the top-level TUI error handler and is rendered as a visible warning banner or modal.

Either way, the user must be able to see which file failed and why, without having to consult the log file.

Acceptance criteria

  • PersonaRegistry.list_personas no longer silently swallows yaml.YAMLError or pydantic.ValidationError.
  • Invalid persona files produce visible, actionable feedback in the TUI (error message includes file path and failure reason).
  • A custom exception type (e.g., InvalidPersonaFileError) is defined and used, or failures are collected and returned as a structured result alongside the valid persona list.
  • All existing Behave scenarios for PersonaRegistry continue to pass.
  • New Behave scenarios cover: (a) a single invalid file among valid ones, (b) all files invalid, (c) mixed YAML and Pydantic errors.
  • nox -e typecheck passes with no suppressions.
  • nox -e coverage_report reports ≥ 97%.

Subtasks

  • Audit PersonaRegistry.list_personas and identify all catch-and-ignore sites.
  • Define a InvalidPersonaFileError (or equivalent) custom exception in the appropriate module.
  • Refactor list_personas to collect failures and either raise or return them alongside valid results.
  • Update the TUI persona list view to display a warning/error indicator for invalid files.
  • Tests (Behave): Add scenarios for invalid YAML persona file, invalid Pydantic schema, and mixed-error cases.
  • Tests (Robot): Add integration test for TUI displaying invalid-persona warning.
  • Verify coverage ≥ 97% via nox -s coverage_report.
  • Run nox (all default sessions), fix any errors.

Definition of Done

This issue is complete when:

  • All subtasks above are completed and checked off.
  • A Git commit is created where the first line of the commit message matches the Commit Message in Metadata exactly, followed by a blank line, then additional lines providing relevant details about the implementation.
  • The commit is pushed to the remote on the branch matching the Branch in Metadata exactly.
  • The commit is submitted as a pull request to master, reviewed, and merged before this issue is marked done.
  • All nox stages pass.
  • Coverage >= 97%.

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

## Metadata - **Branch**: `fix/v3.6.0-list-personas-catch-and-ignore` - **Commit Message**: `fix(persona): surface invalid persona file errors to the user instead of silently ignoring them` - **Milestone**: v3.6.0 - **Parent Epic**: #868 ## Background and context The `PersonaRegistry.list_personas` method in `src/cleveragents/tui/persona/registry.py` (lines 112–113) catches `pydantic.ValidationError` and `yaml.YAMLError` exceptions, logs a warning, and silently continues. This violates the project's **fail-fast / no-error-suppression** architectural principle (CONTRIBUTING.md §Error and Exception Handling): exceptions must only be caught when there is a meaningful recovery path, and must never be caught merely to be logged. When a user creates a persona file with a YAML syntax error or a Pydantic validation error, the persona is silently dropped from the list. The user receives no in-app feedback and must know to inspect the log file to discover the problem. ## Current behavior (for bugs) Invalid persona files are silently ignored. A `WARNING` is emitted to the log file via `_logger.warning(...)`, but no feedback is surfaced in the TUI. The user sees a shorter persona list with no explanation. ```python # src/cleveragents/tui/persona/registry.py lines 112-113 except (yaml.YAMLError, ValidationError) as exc: _logger.warning("Skipping invalid persona file %s: %s", file, exc) ``` ## Expected behavior The application must surface invalid-persona-file errors to the user through the TUI. Acceptable approaches include: 1. Collecting all parse/validation failures and exposing them via a "health check" or "status" view in the persona management UI. 2. Raising a custom, typed exception (e.g., `InvalidPersonaFileError`) that propagates to the top-level TUI error handler and is rendered as a visible warning banner or modal. Either way, the user must be able to see *which* file failed and *why*, without having to consult the log file. ## Acceptance criteria - [ ] `PersonaRegistry.list_personas` no longer silently swallows `yaml.YAMLError` or `pydantic.ValidationError`. - [ ] Invalid persona files produce visible, actionable feedback in the TUI (error message includes file path and failure reason). - [ ] A custom exception type (e.g., `InvalidPersonaFileError`) is defined and used, or failures are collected and returned as a structured result alongside the valid persona list. - [ ] All existing Behave scenarios for `PersonaRegistry` continue to pass. - [ ] New Behave scenarios cover: (a) a single invalid file among valid ones, (b) all files invalid, (c) mixed YAML and Pydantic errors. - [ ] `nox -e typecheck` passes with no suppressions. - [ ] `nox -e coverage_report` reports ≥ 97%. ## Subtasks - [ ] Audit `PersonaRegistry.list_personas` and identify all catch-and-ignore sites. - [ ] Define a `InvalidPersonaFileError` (or equivalent) custom exception in the appropriate module. - [ ] Refactor `list_personas` to collect failures and either raise or return them alongside valid results. - [ ] Update the TUI persona list view to display a warning/error indicator for invalid files. - [ ] Tests (Behave): Add scenarios for invalid YAML persona file, invalid Pydantic schema, and mixed-error cases. - [ ] Tests (Robot): Add integration test for TUI displaying invalid-persona warning. - [ ] Verify coverage ≥ 97% via `nox -s coverage_report`. - [ ] Run `nox` (all default sessions), fix any errors. ## Definition of Done This issue is complete when: - All subtasks above are completed and checked off. - A Git commit is created where the **first line** of the commit message matches the Commit Message in Metadata exactly, followed by a blank line, then additional lines providing relevant details about the implementation. - The commit is pushed to the remote on the branch matching the **Branch** in Metadata exactly. - The commit is submitted as a **pull request** to `master`, reviewed, and **merged** before this issue is marked done. - All nox stages pass. - Coverage >= 97%. --- **Automated by CleverAgents Bot** Supervisor: Bug Hunting | Agent: ca-new-issue-creator
freemo added this to the v3.6.0 milestone 2026-04-03 17:35:10 +00:00
Author
Owner

Issue triaged by project owner:

  • State: Verified
  • Priority: Low — Catch-and-ignore pattern in list_personas suppresses errors. This violates the project's error handling rules but is low-impact.
  • Milestone: v3.6.0
  • MoSCoW: Could Have — Error suppression is bad practice but the persona listing feature works. Defensive improvement.

Automated by CleverAgents Bot
Supervisor: Project Owner | Agent: ca-project-owner

Issue triaged by project owner: - **State**: Verified - **Priority**: Low — Catch-and-ignore pattern in `list_personas` suppresses errors. This violates the project's error handling rules but is low-impact. - **Milestone**: v3.6.0 - **MoSCoW**: Could Have — Error suppression is bad practice but the persona listing feature works. Defensive improvement. --- **Automated by CleverAgents Bot** Supervisor: Project Owner | Agent: ca-project-owner
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
Reference
cleveragents/cleveragents-core#2406
No description provided.