From b11007a8e8546361b009612c13c09b486896e5e5 Mon Sep 17 00:00:00 2001 From: Utku Ufuk Date: Sun, 1 May 2022 01:55:31 +0300 Subject: [PATCH] fix bug where card object was accessed before being decoded --- cmd/habit-service/main.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cmd/habit-service/main.go b/cmd/habit-service/main.go index 4b9010e..f0405d2 100644 --- a/cmd/habit-service/main.go +++ b/cmd/habit-service/main.go @@ -68,13 +68,13 @@ func handleEntrelloRequest(w http.ResponseWriter, req *http.Request) { } var card service.TrelloCard - cell := strings.Split(card.Desc, "\n")[0] if err = json.Unmarshal(body, &card); err != nil { logger.Warn("Invalid request body: %v", err) w.WriteHeader(http.StatusBadRequest) return } + cell := strings.Split(card.Desc, "\n")[0] err = service.UpdateHabit(client, cfg.TimezoneLocation, cell, card.Labels) if err != nil { logger.Error("Could not update habit at cell '%s': %v", cell, err)