-
Notifications
You must be signed in to change notification settings - Fork 30
[Bug] DB migration catch blocks swallow all errors including real failures #233
Copy link
Copy link
Open
Labels
area/artifactArtifact & File System WGArtifact & File System WGbugSomething isn't workingSomething isn't workinggood first issueGood for newcomersGood for newcomers
Description
What happened?
Every ALTER TABLE ADD COLUMN migration in the database initialization is wrapped in a bare try {} catch {} block. This is meant to handle the "column already exists" case, but it also silently swallows genuine errors like type mismatches, disk I/O failures, or permission errors. The schema can end up partially applied with no visibility into what failed.
Where
packages/desktop/src/main/db/index.ts — there are 8 bare catch {} blocks wrapping ALTER TABLE statements.
How to fix
- Open
packages/desktop/src/main/db/index.ts - Find all bare
catch {}blocks wrappingALTER TABLE ADD COLUMNstatements (there are 8) - Replace each bare
catch {}with a catch that checks the error message before swallowing:
try {
sqlite.exec(`ALTER TABLE tasks ADD COLUMN gateway_id TEXT NOT NULL DEFAULT ''`);
} catch (e: unknown) {
const msg = e instanceof Error ? e.message : String(e);
if (!msg.includes("duplicate column") && !msg.includes("already exists")) {
console.error("[db:migration]", msg);
}
}- Apply the same pattern to all 8 catch blocks
- Run
pnpm checkto verify nothing breaks
Expected outcome
Expected errors (duplicate column) are silently handled as before. Unexpected errors (disk I/O, type mismatch) are logged so they can be debugged.
Affected area
Task execution
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
area/artifactArtifact & File System WGArtifact & File System WGbugSomething isn't workingSomething isn't workinggood first issueGood for newcomersGood for newcomers