handleIncidentTimeline: check rows.Err() after the Next() loop #27

Open
opened 2026-10-03 07:02:00 +00:00 by niklas · 0 comments
Owner

handleIncidentTimeline in internal/api/incidents.go loops over rows.Next() to scan timeline events but never checks rows.Err() after the loop, so a connection error or cancellation partway through the scan would silently return a truncated timeline as if it were complete, rather than a 500.

Flagged by the sqlrowserr lint check while working on #26 (unrelated to that issue's scope, so left alone there and filed separately here).

Fix: after the for rows.Next() { ... } loop, add

if err := rows.Err(); err != nil {
    respond(w, http.StatusInternalServerError, errResp("internal error"))
    return
}

matching the pattern other handlers in this package already use after their own rows.Next() loops.

`handleIncidentTimeline` in `internal/api/incidents.go` loops over `rows.Next()` to scan timeline events but never checks `rows.Err()` after the loop, so a connection error or cancellation partway through the scan would silently return a truncated timeline as if it were complete, rather than a 500. Flagged by the `sqlrowserr` lint check while working on #26 (unrelated to that issue's scope, so left alone there and filed separately here). Fix: after the `for rows.Next() { ... }` loop, add ```go if err := rows.Err(); err != nil { respond(w, http.StatusInternalServerError, errResp("internal error")) return } ``` matching the pattern other handlers in this package already use after their own `rows.Next()` loops.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: niklas/terdut-server#27