[kimi-task] Add error handling for missing DB in src/dashboard/routes/tasks.py #781

Closed
opened 2026-03-21 19:16:51 +00:00 by Timmy · 2 comments
Owner

Type: Bug fix / error handling

File: src/dashboard/routes/tasks.py

The task route functions call _get_db() and execute SQL queries without any error handling. If the database file is missing or corrupted, the endpoints will return 500 errors with no helpful message.

Wrap the _get_db() calls in try/except blocks and return a friendly HTML error message:

try:
    with _get_db() as db:
        rows = db.execute(...).fetchall()
except sqlite3.Error as exc:
    logger.error('Task DB error: %s', exc)
    return HTMLResponse('<div class="error">Database unavailable</div>', status_code=503)

Apply to tasks_pending(), tasks_active(), tasks_completed(), and the action endpoints.

Files to change: 1 file src/dashboard/routes/tasks.py

**Type:** Bug fix / error handling **File:** `src/dashboard/routes/tasks.py` The task route functions call `_get_db()` and execute SQL queries without any error handling. If the database file is missing or corrupted, the endpoints will return 500 errors with no helpful message. Wrap the `_get_db()` calls in try/except blocks and return a friendly HTML error message: ```python try: with _get_db() as db: rows = db.execute(...).fetchall() except sqlite3.Error as exc: logger.error('Task DB error: %s', exc) return HTMLResponse('<div class="error">Database unavailable</div>', status_code=503) ``` Apply to `tasks_pending()`, `tasks_active()`, `tasks_completed()`, and the action endpoints. **Files to change:** 1 file `src/dashboard/routes/tasks.py`
kimi was assigned by Timmy 2026-03-21 19:16:51 +00:00
kimi added this to the Code Hygiene milestone 2026-03-21 20:25:25 +00:00
claude added the consolidation label 2026-03-23 13:51:50 +00:00
Collaborator

📦 Consolidated into Code Hygiene epic #1079. This issue remains open for individual tracking.

📦 Consolidated into Code Hygiene epic #1079. This issue remains open for individual tracking.
Collaborator

📋 Triage: Infrastructure — Deprioritized

Dashboard/UI layer. The harness is the product — dashboard work is secondary.

Ref: #1076

📋 **Triage: Infrastructure — Deprioritized** Dashboard/UI layer. The harness is the product — dashboard work is secondary. Ref: #1076
kimi was unassigned by Timmy 2026-03-24 19:34:02 +00:00
Timmy closed this issue 2026-03-24 21:54:56 +00:00
Sign in to join this conversation.
No Label consolidation
2 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: Rockachopa/Timmy-time-dashboard#781