fix(cli): handle missing database in session list command #680

Closed
brent.edwards wants to merge 1 commits from fix/m3-session-list-error into master

1 Commits

Author SHA1 Message Date
Brent E. Edwards a58cfd7b6b fix(cli): handle missing database in session list command
CI / benchmark-publish (pull_request) Has been skipped
CI / lint (pull_request) Successful in 16s
CI / build (pull_request) Successful in 17s
CI / quality (pull_request) Successful in 18s
CI / security (pull_request) Successful in 37s
CI / typecheck (pull_request) Successful in 43s
CI / unit_tests (pull_request) Successful in 3m2s
CI / integration_tests (pull_request) Successful in 3m23s
CI / docker (pull_request) Successful in 40s
CI / coverage (pull_request) Successful in 6m27s
CI / benchmark-regression (pull_request) Successful in 33m46s
Add a 'db' Singleton provider to the DI Container class, backed by a
new _build_db_session_factory() helper that creates a shared SQLAlchemy
engine and sessionmaker.  This resolves the AttributeError raised when
_get_session_service() called container.db() on a container that had no
such provider.

Additional fixes in this commit:

- Ensure structlog routes through stdlib logging to stderr before
  accessing the DI container, preventing debug log lines from
  contaminating structured CLI output (JSON/YAML).

- Output valid JSON/YAML for empty session lists when --format is
  json or yaml (previously always printed plain text).

- Add db_session.commit() after flush in SessionRepository.create()
  so that newly created sessions are immediately visible to subsequent
  queries.

- Remove @tdd_expected_fail tags from all session list (bug #554) and
  session create (bug #570) test scenarios across Behave features and
  Robot Framework suites, since both bugs share the same root cause
  and are resolved by the container fix.

- Fix the session_list_error.feature 'plain output format' assertion
  to match actual plain-format output ('sessions:' instead of the
  Rich table title 'Sessions (').

ISSUES CLOSED: #554, #570
2026-03-11 19:18:33 +00:00