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).
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.
dc62278: handleIncidentTimeline checks rows.Err() after the scan loop and returns a 500.
3613fd5: the same check added to the other loops that lacked it: the incident list (handleListIncidents), the three stats breakdowns in stats.go, and the user list in users.go. sqlrowserr no longer flags anything, and make fmt lint test helm-lint is green.
No new tests: a mid-scan failure can't be triggered against the real Postgres the suite uses.
Fixed on `main`.
- `dc62278`: `handleIncidentTimeline` checks `rows.Err()` after the scan loop and returns a 500.
- `3613fd5`: the same check added to the other loops that lacked it: the incident list (`handleListIncidents`), the three stats breakdowns in `stats.go`, and the user list in `users.go`. `sqlrowserr` no longer flags anything, and `make fmt lint test helm-lint` is green.
No new tests: a mid-scan failure can't be triggered against the real Postgres the suite uses.
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.
handleIncidentTimelineininternal/api/incidents.goloops overrows.Next()to scan timeline events but never checksrows.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
sqlrowserrlint 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, addmatching the pattern other handlers in this package already use after their own
rows.Next()loops.Fixed on
main.dc62278:handleIncidentTimelinechecksrows.Err()after the scan loop and returns a 500.3613fd5: the same check added to the other loops that lacked it: the incident list (handleListIncidents), the three stats breakdowns instats.go, and the user list inusers.go.sqlrowserrno longer flags anything, andmake fmt lint test helm-lintis green.No new tests: a mid-scan failure can't be triggered against the real Postgres the suite uses.
Shipped in v0.39.0 (image published, trivy scan clean). Deploy is pending the wrapper-chart PR: Ryuvia/charts#299. Closing.