fix(todo-sync): provide default priority to prevent SQLite NOT NULL violation#2345
fix(todo-sync): provide default priority to prevent SQLite NOT NULL violation#2345DarkFunct wants to merge 1 commit intocode-yeongyu:devfrom
Conversation
…iolation extractPriority() returns undefined when task metadata has no priority field, but OpenCode's TodoTable requires priority as NOT NULL. This causes a silent SQLiteError that prevents all Task→Todo syncing. Add ?? "medium" fallback so todos always have a valid priority.
|
Thank you for your contribution! Before we can merge this PR, we need you to sign our Contributor License Agreement (CLA). To sign the CLA, please comment on this PR with: This is a one-time requirement. Once signed, all your future contributions will be automatically accepted. I have read the CLA Document and I hereby sign the CLA You can retrigger this bot by commenting recheck in this Pull Request. Posted by the CLA Assistant Lite bot. |
There was a problem hiding this comment.
No issues found across 1 file
Confidence score: 5/5
- Automated review surfaced no issues in the provided summaries.
- No files require special attention.
Auto-approved: Fixes a SQLite NOT NULL constraint violation by providing a safe default value ('medium'), restoring functionality without side effects.
There was a problem hiding this comment.
Pull request overview
Fixes Task→Todo sync failures by ensuring a default priority is always provided when converting a Task into a Todo payload, preventing SQLite NOT NULL violations on todo.priority.
Changes:
- Default
priorityto"medium"whenmetadata.priorityis missing or invalid insyncTaskToTodo().
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| content: task.subject, | ||
| status: todoStatus, | ||
| priority: extractPriority(task.metadata), | ||
| priority: extractPriority(task.metadata) ?? "medium", |
There was a problem hiding this comment.
This changes syncTaskToTodo() so missing/invalid metadata.priority now yields a concrete priority ("medium") instead of undefined. The existing unit tests in src/tools/task/todo-sync.test.ts currently assert priority is undefined for (a) tasks without metadata, (b) tasks without metadata.priority, and (c) invalid priority values, so they will fail unless updated to expect the new default (and/or the desired fallback behavior is adjusted).
| priority: extractPriority(task.metadata) ?? "medium", | |
| priority: extractPriority(task.metadata), |
|
@DarkFunct Thanks for the PR! While I review, could you sign the CLA?
Thank you! |
|
Thanks for this fix — the diagnosis is spot on. The One small thing: the existing tests expect Specifically, these tests:
If not, no worries — I can handle it in a follow-up. Just let me know. |
Problem
syncTaskToTodo()callsextractPriority(task.metadata)which returnsundefinedwhen task metadata has nopriorityfield (the common case — almost no one manually passesmetadata.priority).However, OpenCode's
TodoTableschema definespriorityasNOT NULL:This causes a
SQLiteError: NOT NULL constraint failed: todo.priorityon everyTodo.update()call. The error is silently caught by thetry/catchinsyncTaskTodoUpdate, making Task→Todo sync completely non-functional by default.Root Cause
Fix
One-line change: provide
"medium"as default when no priority is specified. This matches the semantic middle ground and doesn't alter behavior for users who explicitly set priority via metadata.Impact
Without this fix, no tasks created via
task_createortask_updateappear in the OpenCode TUI Todo panel unless the user manually passesmetadata: { priority: "medium" }— which virtually no one does.Summary by cubic
Provide a default "medium" priority in Task→Todo sync to satisfy the TodoTable NOT NULL constraint and restore syncing for tasks without metadata.priority.
Written for commit 229c6b0. Summary will update on new commits.