Skip to content

opencode crashes on startup when SQLite database is corrupted #37821

Description

@leecoder

Bug

When the local SQLite database file becomes corrupted, opencode crashes on startup with:

SQLiteError: database disk image is malformed

or:

SQLiteError: file is not a database

This can happen due to power loss, disk issues, or incomplete writes to the WAL file.

Expected Behavior

opencode should detect corruption, backup the corrupted files, and recreate a fresh database so the user can continue working without manual intervention.

Steps to Reproduce

  1. Corrupt the database file at ~/.local/share/opencode/opencode.db (e.g. write garbage to internal pages while keeping the SQLite header intact)
  2. Run opencode
  3. Observe crash

Environment

  • OS: macOS
  • opencode: latest dev branch

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions