Problem
Editing any category field (name, description, color, active toggle) on the Products page fails with "Failed to save category".
Root Cause
In main/routes/categories.ts:98, the PUT route passes is_active directly from req.body to better-sqlite3:
.run(name, slug, description, parent_id, sort_order, is_active, color, icon, now(), req.params.id);
The frontend sends is_active as a JavaScript boolean (true/false). SQLite has no native boolean type — it uses 0/1. When better-sqlite3 binds a JS boolean, it may not coerce it to integer properly, causing the COALESCE(?, is_active) in the UPDATE to fail.
This affects ALL category updates, not just the active toggle, because the same .run() call includes all parameters — if any parameter binding fails, the entire statement fails.
Additionally, the frontend error handler (products/page.tsx:252) swallows the error with no logging:
catch { toast.error('Failed to save category'); }
The actual error message from the server is never shown or logged.
Fix
1. Backend: Convert boolean to integer (categories.ts)
const activeInt = is_active !== undefined ? (is_active ? 1 : 0) : undefined;
db.prepare(`...`).run(name, slug, description, parent_id, sort_order, activeInt, color, icon, now(), req.params.id);
2. Frontend: Log the actual error (products/page.tsx)
catch (err) {
console.error('[Category] Save error:', err);
toast.error('Failed to save category');
}
Problem
Editing any category field (name, description, color, active toggle) on the Products page fails with "Failed to save category".
Root Cause
In
main/routes/categories.ts:98, the PUT route passesis_activedirectly fromreq.bodytobetter-sqlite3:The frontend sends
is_activeas a JavaScript boolean (true/false). SQLite has no native boolean type — it uses0/1. Whenbetter-sqlite3binds a JS boolean, it may not coerce it to integer properly, causing theCOALESCE(?, is_active)in the UPDATE to fail.This affects ALL category updates, not just the active toggle, because the same
.run()call includes all parameters — if any parameter binding fails, the entire statement fails.Additionally, the frontend error handler (
products/page.tsx:252) swallows the error with no logging:The actual error message from the server is never shown or logged.
Fix
1. Backend: Convert boolean to integer (
categories.ts)2. Frontend: Log the actual error (
products/page.tsx)