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:
dbastrikin
2026-02-22 12:11:05 +02:00
parent 7241802931
commit 842bca9641
2 changed files with 2 additions and 1 deletions

View File

@@ -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
}