Files
cleveragents-core/robot/session_create_error.robot
brent.edwards e732c32981
CI / benchmark-publish (pull_request) Has been skipped
CI / lint (pull_request) Successful in 14s
CI / build (pull_request) Successful in 15s
CI / quality (pull_request) Successful in 17s
CI / security (pull_request) Successful in 36s
CI / typecheck (pull_request) Successful in 38s
CI / unit_tests (pull_request) Successful in 3m3s
CI / integration_tests (pull_request) Successful in 3m32s
CI / docker (pull_request) Successful in 41s
CI / coverage (pull_request) Successful in 8m43s
CI / benchmark-regression (pull_request) Successful in 38m51s
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

54 lines
3.1 KiB
Plaintext

*** Settings ***
Documentation Integration smoke test for session create DI error (bug #570).
... Regression tests verifying that the DI container fix for
... session create works correctly. Bug #570 is now fixed
... (same root cause as bug #554).
Resource ${CURDIR}/common.resource
Library Process
Library OperatingSystem
Suite Setup Setup Test Environment
Suite Teardown Cleanup Test Environment
*** Test Cases ***
Session Create After Init Should Not Error
[Documentation] After agents init, session create --format plain should
... exit 0 and produce a new session rather than a DI
... AttributeError.
[Tags] tdd_bug tdd_bug_570
${tmpdir}= Evaluate __import__('tempfile').mkdtemp(prefix='sce_570_')
${init}= Run Process ${PYTHON} -m cleveragents init sce-test
... timeout=60s cwd=${tmpdir}
Should Be Equal As Integers ${init.rc} 0
... msg=agents init should exit 0 but got ${init.rc}. stderr: ${init.stderr}
${create}= Run Process ${PYTHON} -m cleveragents session create --format plain
... timeout=60s cwd=${tmpdir}
Should Be Equal As Integers ${create.rc} 0
... msg=session create should exit 0 but got ${create.rc}. stderr: ${create.stderr}
Should Not Contain ${create.stderr} AttributeError
... msg=session create should not raise AttributeError: ${create.stderr}
[Teardown] Remove Directory ${tmpdir} recursive=True
Session Create Then List Shows Created Session
[Documentation] After creating a session, listing should show it.
[Tags] tdd_bug tdd_bug_570
${tmpdir}= Evaluate __import__('tempfile').mkdtemp(prefix='sce_570_list_')
${init}= Run Process ${PYTHON} -m cleveragents init sce-list
... timeout=60s cwd=${tmpdir}
Should Be Equal As Integers ${init.rc} 0
... msg=agents init should exit 0 but got ${init.rc}. stderr: ${init.stderr}
${create}= Run Process ${PYTHON} -m cleveragents session create --format plain
... timeout=60s cwd=${tmpdir}
Should Be Equal As Integers ${create.rc} 0
... msg=session create should exit 0 but got ${create.rc}. stderr: ${create.stderr}
Should Not Contain ${create.stderr} AttributeError
... msg=session create should not raise AttributeError: ${create.stderr}
${list}= Run Process ${PYTHON} -m cleveragents session list --format plain
... timeout=60s cwd=${tmpdir}
Should Be Equal As Integers ${list.rc} 0
... msg=session list should exit 0 but got ${list.rc}. stderr: ${list.stderr}
Should Contain ${list.stdout} total:
... msg=Expected 'total:' in plain output: ${list.stdout}
Should Not Contain ${list.stdout} total: 0
... msg=Expected at least one session in list output: ${list.stdout}
[Teardown] Remove Directory ${tmpdir} recursive=True