fix: cast week_start to text in SELECT and add error logging for silent 500
pgx v5 cannot scan a PostgreSQL DATE column directly into a Go string. The WHERE clause already used week_start::text but the SELECT did not, causing GetByWeek to return a scan error that the GenerateMenu handler swallowed without logging (just returned 500). - repository.go: SELECT mp.week_start::text instead of mp.week_start - handler.go: add slog.Error before the silent 500 branch Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -221,6 +221,7 @@ func (h *Handler) GenerateMenu(w http.ResponseWriter, r *http.Request) {
|
||||
// Return the freshly saved plan.
|
||||
plan, err := h.repo.GetByWeek(r.Context(), userID, weekStart)
|
||||
if err != nil || plan == nil {
|
||||
slog.Error("load generated menu", "err", err, "plan_nil", plan == nil)
|
||||
writeError(w, http.StatusInternalServerError, "failed to load generated menu")
|
||||
return
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user