fix(reports): add error handler and improve error messages for diagnosis #51
Reference in New Issue
Block a user
Delete Branch "fix/reports-error-handling"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Root cause
/api/reports/clientswas crashing with a 500 on every request. In the churn-risk query, a raw JavaScriptDateobject was embedded in asqltemplate literal inside.having():postgres-jsdoes not know how to parametrize a rawDatein this position; it throws a type error, the route handler crashes, and Hono returns an empty 500. The frontend then shows "Failed to load report data" with no further detail.Fix (two commits)
87b038d— actual bug fix (CEO)Dateto an ISO 8601 string and add an explicit::timestamptzcast so PostgreSQL handles the comparison correctly:5e185f0— error surfacing (CTO)reportsRouter.onError()so any future unhandled exception returns a JSON{ error, message }500 and logs to stdout, instead of an empty response.Test plan
Fixes #49
🤖 Generated with Claude Code