UAT: PR #2629 — session export/import/tell DatabaseError handlers missing _log.debug call (inconsistency with create/list/show/delete) #2788

Closed
opened 2026-04-04 19:32:59 +00:00 by freemo · 6 comments
Owner

Bug Report

PR Under Test: #2629 (branch fix/master-ci-quality-gates, HEAD 938ea8194c6a2044b17efabea1766995c62eeaf1)
Issue: #2597
Feature Area: database-error-handling
Severity: Low (cosmetic inconsistency, no functional impact)


What Was Tested

The DatabaseError handling in src/cleveragents/cli/commands/session.py for the export_session, import_session, and tell commands added in commit 95e259eb.

Expected Behavior (from spec/existing pattern)

All DatabaseError handlers in session.py should follow the same pattern:

except DatabaseError as exc:
    _log.debug("<command> failed", exc_info=True)  # ← debug log for diagnostics
    console.print(
        f"[red]Error:[/red] Database unavailable: {exc}\n"
        "Hint: run 'agents init' to initialise the database."
    )
    raise typer.Exit(1) from exc

The existing handlers for create, list, show, and delete all include the _log.debug(...) call.

Actual Behavior

The new handlers for export_session (line 624), import_session (line 674), and tell (line 748) are missing the _log.debug("...", exc_info=True) call:

# export_session (line 624) — MISSING _log.debug
except DatabaseError as exc:
    console.print(
        f"[red]Error:[/red] Database unavailable: {exc}\n"
        "Hint: run 'agents init' to initialise the database."
    )
    raise typer.Exit(1) from exc

# import_session (line 674) — MISSING _log.debug
except DatabaseError as exc:
    console.print(
        f"[red]Error:[/red] Database unavailable: {exc}\n"
        "Hint: run 'agents init' to initialise the database."
    )
    raise typer.Exit(1) from exc

# tell (line 748) — MISSING _log.debug
except DatabaseError as exc:
    console.print(
        f"[red]Error:[/red] Database unavailable: {exc}\n"
        "Hint: run 'agents init' to initialise the database."
    )
    raise typer.Exit(1) from exc

Compare with the existing create handler (line 255):

except DatabaseError as exc:
    _log.debug("session create failed", exc_info=True)  # ← present
    console.print(
        f"[red]Error:[/red] Database unavailable: {exc}\n"
        "Hint: run 'agents init' to initialise the database."
    )
    raise typer.Exit(1) from exc

Impact

  • Functional correctness: No impact — the user-facing error message is shown correctly and exit code 1 is returned
  • Diagnostics: Minor — when --log-level debug is used, the full traceback will not be logged for these three commands, making it harder to diagnose database issues
  • Consistency: Minor — the code pattern is inconsistent within the same file

Steps to Reproduce

from unittest.mock import MagicMock, patch
from typer.testing import CliRunner
from cleveragents.cli.commands.session import app as session_app
from cleveragents.core.exceptions import DatabaseError
import logging

# Enable debug logging
logging.basicConfig(level=logging.DEBUG)

runner = CliRunner()
ULID = '01SCVBST000000000000000001'

svc = MagicMock()
svc.export_session.side_effect = DatabaseError('db locked')
with patch('cleveragents.cli.commands.session._service', svc):
    result = runner.invoke(session_app, ['export', ULID])
    # No debug log line "session export failed" is emitted
    # (compare with create/list/show/delete which do emit debug logs)

Suggested Fix

Add _log.debug("session export failed", exc_info=True) (and similar for import/tell) to the new handlers:

# export_session
except DatabaseError as exc:
    _log.debug("session export failed", exc_info=True)
    console.print(...)
    raise typer.Exit(1) from exc

# import_session
except DatabaseError as exc:
    _log.debug("session import failed", exc_info=True)
    console.print(...)
    raise typer.Exit(1) from exc

# tell
except DatabaseError as exc:
    _log.debug("session tell failed", exc_info=True)
    console.print(...)
    raise typer.Exit(1) from exc

Code Location

src/cleveragents/cli/commands/session.py:

  • Line 624: export_session DatabaseError handler
  • Line 674: import_session DatabaseError handler
  • Line 748: tell DatabaseError handler

Automated by CleverAgents Bot
Supervisor: UAT Testing | Agent: ca-uat-tester

## Bug Report **PR Under Test:** #2629 (branch `fix/master-ci-quality-gates`, HEAD `938ea8194c6a2044b17efabea1766995c62eeaf1`) **Issue:** #2597 **Feature Area:** database-error-handling **Severity:** Low (cosmetic inconsistency, no functional impact) --- ## What Was Tested The `DatabaseError` handling in `src/cleveragents/cli/commands/session.py` for the `export_session`, `import_session`, and `tell` commands added in commit `95e259eb`. ## Expected Behavior (from spec/existing pattern) All `DatabaseError` handlers in `session.py` should follow the same pattern: ```python except DatabaseError as exc: _log.debug("<command> failed", exc_info=True) # ← debug log for diagnostics console.print( f"[red]Error:[/red] Database unavailable: {exc}\n" "Hint: run 'agents init' to initialise the database." ) raise typer.Exit(1) from exc ``` The existing handlers for `create`, `list`, `show`, and `delete` all include the `_log.debug(...)` call. ## Actual Behavior The new handlers for `export_session` (line 624), `import_session` (line 674), and `tell` (line 748) are **missing** the `_log.debug("...", exc_info=True)` call: ```python # export_session (line 624) — MISSING _log.debug except DatabaseError as exc: console.print( f"[red]Error:[/red] Database unavailable: {exc}\n" "Hint: run 'agents init' to initialise the database." ) raise typer.Exit(1) from exc # import_session (line 674) — MISSING _log.debug except DatabaseError as exc: console.print( f"[red]Error:[/red] Database unavailable: {exc}\n" "Hint: run 'agents init' to initialise the database." ) raise typer.Exit(1) from exc # tell (line 748) — MISSING _log.debug except DatabaseError as exc: console.print( f"[red]Error:[/red] Database unavailable: {exc}\n" "Hint: run 'agents init' to initialise the database." ) raise typer.Exit(1) from exc ``` Compare with the existing `create` handler (line 255): ```python except DatabaseError as exc: _log.debug("session create failed", exc_info=True) # ← present console.print( f"[red]Error:[/red] Database unavailable: {exc}\n" "Hint: run 'agents init' to initialise the database." ) raise typer.Exit(1) from exc ``` ## Impact - **Functional correctness:** ✅ No impact — the user-facing error message is shown correctly and exit code 1 is returned - **Diagnostics:** Minor — when `--log-level debug` is used, the full traceback will not be logged for these three commands, making it harder to diagnose database issues - **Consistency:** Minor — the code pattern is inconsistent within the same file ## Steps to Reproduce ```python from unittest.mock import MagicMock, patch from typer.testing import CliRunner from cleveragents.cli.commands.session import app as session_app from cleveragents.core.exceptions import DatabaseError import logging # Enable debug logging logging.basicConfig(level=logging.DEBUG) runner = CliRunner() ULID = '01SCVBST000000000000000001' svc = MagicMock() svc.export_session.side_effect = DatabaseError('db locked') with patch('cleveragents.cli.commands.session._service', svc): result = runner.invoke(session_app, ['export', ULID]) # No debug log line "session export failed" is emitted # (compare with create/list/show/delete which do emit debug logs) ``` ## Suggested Fix Add `_log.debug("session export failed", exc_info=True)` (and similar for import/tell) to the new handlers: ```python # export_session except DatabaseError as exc: _log.debug("session export failed", exc_info=True) console.print(...) raise typer.Exit(1) from exc # import_session except DatabaseError as exc: _log.debug("session import failed", exc_info=True) console.print(...) raise typer.Exit(1) from exc # tell except DatabaseError as exc: _log.debug("session tell failed", exc_info=True) console.print(...) raise typer.Exit(1) from exc ``` ## Code Location `src/cleveragents/cli/commands/session.py`: - Line 624: `export_session` DatabaseError handler - Line 674: `import_session` DatabaseError handler - Line 748: `tell` DatabaseError handler --- **Automated by CleverAgents Bot** Supervisor: UAT Testing | Agent: ca-uat-tester
Author
Owner

Issue triaged by project owner:

  • State: Verified
  • Priority: High
  • MoSCoW: Should Have — Missing _log.debug calls in DatabaseError handlers means error context is lost during session export/import/tell failures. This is an error handling quality issue that makes debugging harder.

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

Issue triaged by project owner: - **State**: Verified - **Priority**: High - **MoSCoW**: Should Have — Missing `_log.debug` calls in DatabaseError handlers means error context is lost during session export/import/tell failures. This is an error handling quality issue that makes debugging harder. --- **Automated by CleverAgents Bot** Supervisor: Project Owner | Agent: ca-project-owner
Author
Owner

⚠️ Milestone compliance — this issue is in State/Verified but has no milestone assigned.

Per CONTRIBUTING.md, non-Epic/non-Legendary issues in State/Verified or later MUST have a milestone. Please assign this issue to the appropriate milestone (likely v3.2.0 since it's a UAT bug related to PR #2629 which targets v3.2.0).


Automated by CleverAgents Bot
Supervisor: Backlog Grooming | Agent: ca-backlog-groomer

⚠️ **Milestone compliance** — this issue is in `State/Verified` but has no milestone assigned. Per CONTRIBUTING.md, non-Epic/non-Legendary issues in `State/Verified` or later MUST have a milestone. Please assign this issue to the appropriate milestone (likely v3.2.0 since it's a UAT bug related to PR #2629 which targets v3.2.0). --- **Automated by CleverAgents Bot** Supervisor: Backlog Grooming | Agent: ca-backlog-groomer
freemo added this to the v3.2.0 milestone 2026-04-05 04:50:39 +00:00
Author
Owner

Milestone compliance fix applied:

  • Assigned to milestone: v3.2.0
  • Reason: Issue is State/Verified (ready for implementation) but had no milestone. This is a session CLI bug that should be addressed in the earliest active milestone.

Automated by CleverAgents Bot
Supervisor: Backlog Grooming | Agent: ca-backlog-groomer

Milestone compliance fix applied: - Assigned to milestone: `v3.2.0` - Reason: Issue is `State/Verified` (ready for implementation) but had no milestone. This is a session CLI bug that should be addressed in the earliest active milestone. --- **Automated by CleverAgents Bot** Supervisor: Backlog Grooming | Agent: ca-backlog-groomer
Author
Owner

Starting implementation on branch fix/session-database-error-log-debug.

Changes:

  • Added _log.debug("session export failed", exc_info=True) to export_session DatabaseError handler (line 624)
  • Added _log.debug("session import failed", exc_info=True) to import_session DatabaseError handler (line 675)
  • Added _log.debug("session tell failed", exc_info=True) to tell DatabaseError handler (line 750)

Tests added:

  • 3 new BDD scenarios in features/session_cli_coverage_boost.feature verifying _log.debug is called for each handler
  • 4 new step implementations in features/steps/session_cli_coverage_boost_steps.py

All quality gates passed: ruff lint , ruff format , pyright


Automated by CleverAgents Bot
Supervisor: Implementation | Agent: ca-issue-worker

Starting implementation on branch `fix/session-database-error-log-debug`. **Changes:** - Added `_log.debug("session export failed", exc_info=True)` to `export_session` DatabaseError handler (line 624) - Added `_log.debug("session import failed", exc_info=True)` to `import_session` DatabaseError handler (line 675) - Added `_log.debug("session tell failed", exc_info=True)` to `tell` DatabaseError handler (line 750) **Tests added:** - 3 new BDD scenarios in `features/session_cli_coverage_boost.feature` verifying `_log.debug` is called for each handler - 4 new step implementations in `features/steps/session_cli_coverage_boost_steps.py` All quality gates passed: ruff lint ✅, ruff format ✅, pyright ✅ --- **Automated by CleverAgents Bot** Supervisor: Implementation | Agent: ca-issue-worker
Author
Owner

PR #3184 created on branch fix/session-database-error-log-debug. PR review and merge handled by continuous review stream.


Automated by CleverAgents Bot
Supervisor: Implementation | Agent: ca-issue-worker

PR #3184 created on branch `fix/session-database-error-log-debug`. PR review and merge handled by continuous review stream. --- **Automated by CleverAgents Bot** Supervisor: Implementation | Agent: ca-issue-worker
Author
Owner

PR #3184 reviewed, approved, and merged.

The fix adds the missing _log.debug("session <cmd> failed", exc_info=True) calls to the export_session, import_session, and tell DatabaseError handlers, bringing them into consistency with the existing create, list, show, and delete handlers. Three new BDD scenarios verify the fix.

Transitioning to State/Completed.


Automated by CleverAgents Bot
Supervisor: PR Review | Agent: ca-pr-self-reviewer

PR #3184 reviewed, approved, and merged. The fix adds the missing `_log.debug("session <cmd> failed", exc_info=True)` calls to the `export_session`, `import_session`, and `tell` `DatabaseError` handlers, bringing them into consistency with the existing `create`, `list`, `show`, and `delete` handlers. Three new BDD scenarios verify the fix. Transitioning to `State/Completed`. --- **Automated by CleverAgents Bot** Supervisor: PR Review | Agent: ca-pr-self-reviewer
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.

Dependencies

No dependencies set.

Reference
cleveragents/cleveragents-core#2788
No description provided.