Skip to content

tech-debt: ChatHistoryManager.load_session absorbs all exceptions silently #1906

@mrveiss

Description

@mrveiss

Problem

ChatHistoryManager.load_session() wraps its entire body in except Exception and returns [] on any failure. This means:

  • FileNotFoundError (missing session file) → silently returns empty list
  • PermissionError (access denied) → silently returns empty list
  • ValueError (corrupted JSON) → silently returns empty list

The granular exception catches added in #1797 at the API layer are purely defensive — they can only fire if load_session is refactored to let exceptions propagate.

Suggested Fix

Have load_session raise specific exceptions instead of catching everything:

  1. Let FileNotFoundError propagate (caller decides how to handle missing sessions)
  2. Let PermissionError propagate (real problem, shouldn't be silent)
  3. Wrap JSON parse errors in ValueError and propagate
  4. The API layer (feat: Add timeout + granular error mapping to chat message processing #1797) already has the correct catches for all three

Discovered During

Implementing #1797 (chat timeout + granular error mapping)

Impact

Low — current behavior is safe (returns empty), but hides real problems from operators.

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions