[LOW] Log JSON parse/read errors with file path - distinguish missing DB from corrupt JSON #39

Closed
opened 2026-06-09 00:03:13 +00:00 by Mark · 0 comments
Owner

Location: backend/src/database.ts:287-292

Problem: catch { return [] } silently swallows all parse/read errors. Data corruption silently becomes an empty result.

Impact: Hard to debug production issues; silent data loss.

Fix:

catch (err) {
  const msg = err instanceof Error ? err.message : String(err);
  if (err.code === "ENOENT") {
    logger.info(`DB file missing, starting fresh: ${path}`);
    return [];
  }
  logger.error(`Corrupt JSON in ${path}: ${msg}`);
  throw err;
}

Effort: ~20 mins

**Location:** `backend/src/database.ts:287-292` **Problem:** `catch { return [] }` silently swallows all parse/read errors. Data corruption silently becomes an empty result. **Impact:** Hard to debug production issues; silent data loss. **Fix:** ```ts catch (err) { const msg = err instanceof Error ? err.message : String(err); if (err.code === "ENOENT") { logger.info(`DB file missing, starting fresh: ${path}`); return []; } logger.error(`Corrupt JSON in ${path}: ${msg}`); throw err; } ``` **Effort:** ~20 mins
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
Mark/subvault#39
No description provided.