fix(04-WR-01): check UpdateTask errors in TaskReorderHandler instead of discarding
Both the single-task branch and the main loop were using _, _ = to discard UpdateTask errors. Now both log the error and return 500 so the client is never shown a false success when DB writes fail. Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
392b5321be
commit
3d32f2d92f
1 changed files with 14 additions and 4 deletions
|
|
@ -445,13 +445,18 @@ func TaskReorderHandler(deps TasksDeps) http.HandlerFunc {
|
||||||
if _, scanErr := fmt.Sscanf(positionVal, "%d", &newPos); scanErr != nil || newPos <= 0 {
|
if _, scanErr := fmt.Sscanf(positionVal, "%d", &newPos); scanErr != nil || newPos <= 0 {
|
||||||
newPos = 100
|
newPos = 100
|
||||||
}
|
}
|
||||||
_, _ = deps.Queries.UpdateTask(ctx, sqlc.UpdateTaskParams{
|
if _, err := deps.Queries.UpdateTask(ctx, sqlc.UpdateTaskParams{
|
||||||
ID: existing.ID,
|
ID: existing.ID,
|
||||||
Title: existing.Title,
|
Title: existing.Title,
|
||||||
Description: existing.Description,
|
Description: existing.Description,
|
||||||
Status: newStatus,
|
Status: newStatus,
|
||||||
Position: newPos,
|
Position: newPos,
|
||||||
})
|
}); err != nil {
|
||||||
|
slog.Default().Error("tasks reorder: UpdateTask failed (single)",
|
||||||
|
"task_id", existing.ID, "err", err)
|
||||||
|
http.Error(w, "internal server error", http.StatusInternalServerError)
|
||||||
|
return
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
tasks, _ := deps.Queries.ListTasksByTablo(ctx, tablo.ID)
|
tasks, _ := deps.Queries.ListTasksByTablo(ctx, tablo.ID)
|
||||||
|
|
@ -486,13 +491,18 @@ func TaskReorderHandler(deps TasksDeps) http.HandlerFunc {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Preserve title+description; only update status+position (T-04-08).
|
// Preserve title+description; only update status+position (T-04-08).
|
||||||
_, _ = deps.Queries.UpdateTask(ctx, sqlc.UpdateTaskParams{
|
if _, err := deps.Queries.UpdateTask(ctx, sqlc.UpdateTaskParams{
|
||||||
ID: existing.ID,
|
ID: existing.ID,
|
||||||
Title: existing.Title,
|
Title: existing.Title,
|
||||||
Description: existing.Description,
|
Description: existing.Description,
|
||||||
Status: newStatus,
|
Status: newStatus,
|
||||||
Position: newPos,
|
Position: newPos,
|
||||||
})
|
}); err != nil {
|
||||||
|
slog.Default().Error("tasks reorder: UpdateTask failed",
|
||||||
|
"task_id", existing.ID, "err", err)
|
||||||
|
http.Error(w, "internal server error", http.StatusInternalServerError)
|
||||||
|
return
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
tasks, err := deps.Queries.ListTasksByTablo(ctx, tablo.ID)
|
tasks, err := deps.Queries.ListTasksByTablo(ctx, tablo.ID)
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue