Skip to content

fix(kanban): avoid fragile failure-column renames (salvage #20848) - #20855

Merged
kshitijk4poor merged 2 commits into
mainfrom
fix/kanban-20848-salvage
May 6, 2026
Merged

fix(kanban): avoid fragile failure-column renames (salvage #20848)#20855
kshitijk4poor merged 2 commits into
mainfrom
fix/kanban-20848-salvage

Conversation

@kshitijk4poor

Copy link
Copy Markdown
Collaborator

Salvage of #20848 by @helix4u onto current main.

What this fixes

After the #20410 update (unified Kanban failure counter), existing users' Kanban dispatcher crashed immediately on startup with:

sqlite3.OperationalError: no such column: "spawn_failures"

The #20410 migration used ALTER TABLE ... RENAME COLUMN spawn_failures TO consecutive_failures. This worked on DBs that had spawn_failures, but crashed on older installs that never had that column at all. Reported in issue #20842 by @emm3ttarmstrong.

This PR replaces the fragile RENAME COLUMN with an ADD-first-then-copy approach:

  1. Always ALTER TABLE ADD COLUMN consecutive_failures (safe even if spawn_failures never existed)
  2. Only UPDATE ... SET consecutive_failures = COALESCE(spawn_failures, 0) when the legacy column exists
  3. Old columns are left in place harmlessly — no RENAME, no DROP

Additive on top of helix4u's original fix. All four DB shapes are handled:

  • Scenario A (no legacy columns at all) — was the reported crash, now adds with default 0 ✅
  • Scenario B (has spawn_failures only) — ADD + COPY ✅
  • Scenario C (already has consecutive_failures) — full no-op ✅
  • Scenario D (has both) — full no-op, counter preserved ✅

Changes from original PR

Tests

162 passed, 1 skipped — up from 160 in the original PR.

Fixes #20842
Closes #20848

@alt-glitch alt-glitch added type/bug Something isn't working P3 Low — cosmetic, nice to have comp/plugins Plugin system and bundled plugins labels May 6, 2026
- Expand migration comment to name the primary failure mode (missing
  column OperationalError from #20842) ahead of the secondary SQLite
  schema-reparse concern; also document the stale-cols-snapshot invariant
- Add clarifying comments on from_row() legacy fallback branches noting
  they are belt-and-suspenders dead code post-migration
- Add task_events comment in existing test explaining why the table is
  required by the migrator
- Add test_legacy_migration_no_legacy_columns_at_all: Scenario A —
  explicitly asserts the exact #20842 crash no longer occurs and that
  consecutive_failures defaults to 0 on a DB that never had spawn_failures
- Add test_legacy_migration_both_columns_already_present: Scenario D —
  asserts the migration is a no-op when both columns already exist,
  preserving the existing counter value
@kshitijk4poor
kshitijk4poor force-pushed the fix/kanban-20848-salvage branch from b1d11e5 to 7b7967e Compare May 6, 2026 18:24
@kshitijk4poor
kshitijk4poor merged commit a2ff193 into main May 6, 2026
10 of 11 checks passed
@kshitijk4poor
kshitijk4poor deleted the fix/kanban-20848-salvage branch May 6, 2026 18:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

comp/plugins Plugin system and bundled plugins P3 Low — cosmetic, nice to have type/bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Kanban migration fails after update: no such column spawn_failures

3 participants