UAT: sessions table missing name column in migration — session list and session show fail with OperationalError: no such column: sessions.name #2001

Open
opened 2026-04-03 00:33:31 +00:00 by freemo · 0 comments
Owner

Metadata

  • Branch: fix/sessions-migration-missing-name-column
  • Commit Message: fix(persistence): add missing name column to sessions table migration
  • Milestone: v3.5.0
  • Parent Epic: #397

Description

The Session domain model (src/cleveragents/domain/models/core/session.py) has a name field (added in a recent commit), but the database migration alembic/versions/a7_001_session_persistence.py does not include a name column in the sessions table. No subsequent migration adds this column either.

What was tested

Running agents init <project> followed by agents session list in a fresh directory.

Expected behavior

agents session list should exit 0 and show "No sessions found" (or an empty list).

Actual behavior

agents session list fails with exit code 1 and the error:

Failed to list sessions: (sqlite3.OperationalError) no such column: sessions.name
[SQL: SELECT sessions.session_id AS sessions_session_id, sessions.actor_name AS sessions_actor_name, sessions.name AS sessions_name, ...
FROM sessions ORDER BY sessions.created_at]

The retry decorator retries 3 times (with 0.5s waits) before giving up, producing:

Error: Database unavailable: Failed to list sessions: (sqlite3.OperationalError)
no such column: sessions.name
Hint: run 'agents init' to initialise the database.

Root cause

The Session model defines:

name: str | None = Field(
    default=None,
    description="Optional human-readable name for this session",
)

But alembic/versions/a7_001_session_persistence.py creates the sessions table without a name column. No subsequent migration adds it.

Impact

  • session list fails completely (exit code 1)
  • session show fails completely (exit code 1)
  • session_list_error.robot integration tests fail (tagged tdd_issue_554, expected to pass)
  • session_create_error.robot integration tests fail (tagged tdd_issue_570, expected to pass)
  • The session_persistence.robot Session Export And Import Round Trip test fails

Steps to reproduce

git clone https://git.cleverthis.com/cleveragents/cleveragents-core.git
cd cleveragents-core
uv sync --extra tests
mkdir /tmp/test_session && cd /tmp/test_session
python -m cleveragents init test-proj
python -m cleveragents session list
# Error: no such column: sessions.name

Code locations

  • src/cleveragents/domain/models/core/session.py line ~185: name: str | None = Field(...)
  • alembic/versions/a7_001_session_persistence.py: Missing name column in sessions table creation

Fix required

Add a new Alembic migration that adds the name column to the sessions table:

op.add_column('sessions', sa.Column('name', sa.String(255), nullable=True))

Subtasks

  • Create a new Alembic migration file (e.g. alembic/versions/a7_002_sessions_add_name.py) that adds name VARCHAR(255) NULL to the sessions table
  • Verify upgrade() adds the column and downgrade() drops it correctly
  • Confirm agents init followed by agents session list exits 0 on a fresh database
  • Confirm agents session show exits 0 (or expected error) on a fresh database
  • Confirm session_list_error.robot (tagged tdd_issue_554) passes
  • Confirm session_create_error.robot (tagged tdd_issue_570) passes
  • Confirm session_persistence.robot Session Export And Import Round Trip passes
  • Run full nox suite and confirm all stages pass

Definition of Done

  • New Alembic migration adds name column to sessions table with correct nullability
  • agents session list exits 0 on a fresh database after agents init
  • agents session show exits 0 (or expected non-DB error) on a fresh database
  • session_list_error.robot integration tests pass (tagged tdd_issue_554)
  • session_create_error.robot integration tests pass (tagged tdd_issue_570)
  • session_persistence.robot Session Export And Import Round Trip test passes
  • All nox stages pass
  • Coverage >= 97%

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

## Metadata - **Branch**: `fix/sessions-migration-missing-name-column` - **Commit Message**: `fix(persistence): add missing name column to sessions table migration` - **Milestone**: v3.5.0 - **Parent Epic**: #397 ## Description The `Session` domain model (`src/cleveragents/domain/models/core/session.py`) has a `name` field (added in a recent commit), but the database migration `alembic/versions/a7_001_session_persistence.py` does not include a `name` column in the `sessions` table. No subsequent migration adds this column either. ### What was tested Running `agents init <project>` followed by `agents session list` in a fresh directory. ### Expected behavior `agents session list` should exit 0 and show "No sessions found" (or an empty list). ### Actual behavior `agents session list` fails with exit code 1 and the error: ``` Failed to list sessions: (sqlite3.OperationalError) no such column: sessions.name [SQL: SELECT sessions.session_id AS sessions_session_id, sessions.actor_name AS sessions_actor_name, sessions.name AS sessions_name, ... FROM sessions ORDER BY sessions.created_at] ``` The retry decorator retries 3 times (with 0.5s waits) before giving up, producing: ``` Error: Database unavailable: Failed to list sessions: (sqlite3.OperationalError) no such column: sessions.name Hint: run 'agents init' to initialise the database. ``` ### Root cause The `Session` model defines: ```python name: str | None = Field( default=None, description="Optional human-readable name for this session", ) ``` But `alembic/versions/a7_001_session_persistence.py` creates the `sessions` table without a `name` column. No subsequent migration adds it. ### Impact - `session list` fails completely (exit code 1) - `session show` fails completely (exit code 1) - `session_list_error.robot` integration tests fail (tagged `tdd_issue_554`, expected to pass) - `session_create_error.robot` integration tests fail (tagged `tdd_issue_570`, expected to pass) - The `session_persistence.robot` `Session Export And Import Round Trip` test fails ### Steps to reproduce ```bash git clone https://git.cleverthis.com/cleveragents/cleveragents-core.git cd cleveragents-core uv sync --extra tests mkdir /tmp/test_session && cd /tmp/test_session python -m cleveragents init test-proj python -m cleveragents session list # Error: no such column: sessions.name ``` ### Code locations - `src/cleveragents/domain/models/core/session.py` line ~185: `name: str | None = Field(...)` - `alembic/versions/a7_001_session_persistence.py`: Missing `name` column in `sessions` table creation ### Fix required Add a new Alembic migration that adds the `name` column to the `sessions` table: ```python op.add_column('sessions', sa.Column('name', sa.String(255), nullable=True)) ``` ## Subtasks - [ ] Create a new Alembic migration file (e.g. `alembic/versions/a7_002_sessions_add_name.py`) that adds `name VARCHAR(255) NULL` to the `sessions` table - [ ] Verify `upgrade()` adds the column and `downgrade()` drops it correctly - [ ] Confirm `agents init` followed by `agents session list` exits 0 on a fresh database - [ ] Confirm `agents session show` exits 0 (or expected error) on a fresh database - [ ] Confirm `session_list_error.robot` (tagged `tdd_issue_554`) passes - [ ] Confirm `session_create_error.robot` (tagged `tdd_issue_570`) passes - [ ] Confirm `session_persistence.robot` `Session Export And Import Round Trip` passes - [ ] Run full `nox` suite and confirm all stages pass ## Definition of Done - [ ] New Alembic migration adds `name` column to `sessions` table with correct nullability - [ ] `agents session list` exits 0 on a fresh database after `agents init` - [ ] `agents session show` exits 0 (or expected non-DB error) on a fresh database - [ ] `session_list_error.robot` integration tests pass (tagged `tdd_issue_554`) - [ ] `session_create_error.robot` integration tests pass (tagged `tdd_issue_570`) - [ ] `session_persistence.robot` `Session Export And Import Round Trip` test passes - [ ] All nox stages pass - [ ] Coverage >= 97% --- **Automated by CleverAgents Bot** Supervisor: UAT Testing | Agent: ca-uat-tester
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#2001
No description provided.