fix(tasks): handleCancel crashes with NOT NULL constraint failed: task_history.user #1108
Labels
No labels
area:agents
area:dashboard
area:database
area:design
area:design-review
area:flows
area:infra
area:meta
area:security
area:sessions
area:webhook
area:workdir
security
type:bug
type:chore
type:meta
type:user-story
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
charles/claude-hooks#1108
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
User story
As an operator using
POST /api/cancelto kill a stuck task, I want the cancel to succeed and persist acancelledrow intask_history, so that the cancel attempt isn't swallowed by an uncaught SQLite exception.Repro
2026-05-11 ~15:26 UTC:
The cancel succeeded in killing the cursor-agent process, but the post-cancel
persistTaskinsert failed because the cancel handler didn't populatetask_history.user.Root cause
handleCancel(apps/server/src/main.ts:1285) builds a task_history payload without auserfield. Thetask_historyschema declaresuser TEXT NOT NULL(seePRAGMA table_info(task_history)). Insert fails with constraint error 1299.Acceptance criteria
Fix
handleCancelpopulatestask_history.userfrom the in-memory running task record (theuserfield set at dispatch time)."<unknown>"rather than NULL — keep the NOT NULL invariant.unhandledRejection.Tests
POST /api/cancel, asserttask_historyrow exists withstatus='cancelled'+ correctuser.unhandledRejectionfires from the cancel path.Related (out of scope but worth noting in PR)
References
apps/server/src/main.ts:1285(handleCancel) +apps/server/src/infrastructure/database/task-store.ts:206(persistTask).