Skip to content

Fix selected_content migration that broke /api/activity (assistant stuck at "Queued 0%") - #201

Merged
davior merged 1 commit into
mainfrom
claude/compassionate-ramanujan-b5v9k7
Oct 5, 2026
Merged

davior merged 1 commit into
mainfrom
claude/compassionate-ramanujan-b5v9k7

Conversation

@davior

@davior davior commented Oct 5, 2026

Copy link
Copy Markdown
Owner

Problem

After #200 ("Render Selected"), the assistant appeared to hang. The task indicator showed Queued 0% and the chat showed Thinking… indefinitely. The reply had actually been written: it showed up after a page refresh.

Every 2 s poll of GET /api/activity?limit=25 was returning 500 Internal Server Error (confirmed from a browser HAR capture).

Root cause

The new migration ran:

ALTER TABLE video_render_job ADD COLUMN selected_content TEXT

The table is actually videorenderjob, SQLModel's default name, which every other migration in database.py already uses. The except Exception: pass around it swallowed the "no such table" error. As a result, on any existing database:

  • the column was never added
  • the VideoRenderJob model still declared it
  • every read of the video table raised no such column: videorenderjob.selected_content

/api/activity reads every job table in one union, so that one missing column made the whole endpoint fail. The activity store keeps the last known state when a poll fails. That froze assistant turns at their initial queued state even though the worker had completed them.

Fresh databases were unaffected because create_all builds the column directly, which is why tests didn't catch it.

Fix

  • Correct the table name in the migration. On the next backend startup, the ALTER adds the column; no manual DB step is needed.
  • New backend/tests/test_migrations.py:
    • migrating an old database (column dropped) restores selected_content
    • the activity listing reads cleanly after migrating an old database
    • a guard that every ALTER TABLE … ADD COLUMN in database.py names a table that exists, which catches this whole class of silent failure

All three tests fail on the previous code and pass with the fix. Full backend suite: 1141 passed.

Video render creation and estimation on existing installs were broken by the same missing column and are fixed by this too.

🤖 Generated with Claude Code

https://claude.ai/code/session_01VXSCyWni3bUs3umLurV7wP


Generated by Claude Code

The "Render Selected" migration ran `ALTER TABLE video_render_job`, but the
table is `videorenderjob` (SQLModel's default name, as every other migration
uses). The error was swallowed, so on any existing database the column never
arrived while the model still declared it — and every read of the video job
table raised `no such column: videorenderjob.selected_content`.

`GET /api/activity` reads every job table in one union, so it returned 500 on
every 2s poll. The store keeps the last known state on a failed poll, which
left assistant turns showing "Queued 0%" and "Thinking..." forever even
though the worker had finished and written the reply into the chat.

The corrected ALTER runs on the next startup and adds the column; no manual
step needed. Tests cover an old database being migrated, the activity listing
reading afterwards, and a guard that every ADD COLUMN names a real table.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01VXSCyWni3bUs3umLurV7wP
@davior
davior marked this pull request as ready for review October 5, 2026 13:39
@davior
davior merged commit c4b80e1 into main Oct 5, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants