Files
temp/features/tdd_session_list_missing_db.feature
brent.edwards e732c32981 fix(cli): handle missing database in session list command
Register PersistentSessionService in the DI Container so that
'agents session list' (and all other session subcommands) no longer
throw AttributeError due to a missing 'db' provider.

Changes:
- Add _build_session_service() factory and session_service provider to
  Container, with targeted table creation for session/session_messages
  only (avoids bypassing Alembic for the full schema).
- Add auto_commit parameter to SessionRepository and
  SessionMessageRepository; when True each method commits and closes
  its own database session, preventing resource leaks in CLI context.
- Rewrite _get_session_service() to resolve via container.session_service()
  with module-level caching.
- Add (DatabaseError, AttributeError) error handling with logging to all
  seven session subcommands (list, create, show, delete, export, import,
  tell).
- Remove @tdd_expected_fail tags from all session test files so they run
  as proper regression tests.

ISSUES CLOSED: #554, #570, #680
2026-03-12 16:16:41 +00:00

32 lines
1.5 KiB
Gherkin

@tdd_bug @tdd_bug_680
Feature: TDD Bug #680 — session list with missing database
As a developer
I want to verify that `agents session list` handles a missing database
gracefully
So that the bug is captured and will be caught by a regression test
The CLI `session list` command should work even when no database file
exists. Currently `_get_session_service()` calls `container.db()`,
but the Container class has no `db` provider, causing an
AttributeError at runtime. Even after the DI wiring is fixed, the
database file itself must be auto-created so the command returns an
empty list rather than crashing.
Scenario: Session list with missing database exits successfully
Given a CLI runner with no database file present
When I invoke session list with missing db
Then the session list missing db command should exit successfully
And the session list missing db output should not contain "AttributeError"
Scenario: Session list with missing database produces valid JSON
Given a CLI runner with no database file present
When I invoke session list with missing db and format json
Then the session list missing db command should exit successfully
And the session list missing db output should be valid JSON
Scenario: Session list with missing database shows empty list
Given a CLI runner with no database file present
When I invoke session list with missing db
Then the session list missing db command should exit successfully
And the session list missing db output should indicate no sessions