fix(server): return a clear "restart required" error on missing DB schema#897
fix(server): return a clear "restart required" error on missing DB schema#897wideplain wants to merge 1 commit into
Conversation
…hema When a DB-backed action hits a "no such table/column" SQLite error, the global error handler previously returned a generic 500 INTERNAL_ERROR. This happens in a very common real-world situation: the on-disk package was updated (introducing new schema/migrations) but the running server process was never restarted, so initializeDatabase() never created the new tables for the running process. The result is that session/project delete, archive and rename silently fail and look like nothing happened. Map that specific failure to a 503 with code SCHEMA_NOT_INITIALIZED and an actionable message telling the user to restart the server, instead of hiding it behind a generic 500. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
📝 WalkthroughWalkthroughThe global Express error handler in ChangesSQLite Schema Error Handling
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Problem
When a DB-backed request hits a SQLite
no such table/no such columnerror, the global error handler inserver/index.jsreturns a generic500 INTERNAL_ERROR.This occurs in a very common real-world situation: the package is updated on disk (new schema / migrations in
initializeDatabase()), but the running server process is not restarted. Because the new schema is only applied at startup, the long-lived old process keeps running against a DB that lacks the new tables (projects,sessions, …). DB-backed actions — deleting/archiving/renaming a session or project — then throwno such table: sessionsand fail silently from the user's point of view (the trash icon appears to do nothing).Sidebar listings still work because they're read from disk (
~/.claude/projects/*/*.jsonl), which makes the failure even more confusing: items are visible but can't be mutated.Fix
In the global error handler, detect this specific class of error (
SQLITE_ERROR/SqliteErrorwith ano such table|columnmessage) and return a503with codeSCHEMA_NOT_INITIALIZEDand an actionable message asking the user to restart the server, instead of burying it in a generic 500.No behavior change for any other error.
Notes
🤖 Generated with Claude Code
Summary by CodeRabbit