buildTripsForLocationEntries uses a nil first return value to signal "the response has already been written". It also returns result when ctx.Err() != nil, and result is still nil if cancellation happens before the first entry is appended.
The caller then does:
result := api.buildTripsForLocationEntries(...)
if result == nil {
return
}
So on an early cancellation the handler returns without writing anything, short-circuiting before the ctx.Err() check that would otherwise call clientCanceledResponse — the client sees a 200 with no body.
The nil sentinel is overloaded: it means both "already responded" and "no entries yet". Splitting those (an explicit responded bool, or a sentinel error) would fix it.
Originally raised by CodeRabbit on #1317; I verified it is pre-existing on main and not introduced by that PR, so it belongs here rather than as a change request on the stack.
buildTripsForLocationEntriesuses a nil first return value to signal "the response has already been written". It also returnsresultwhenctx.Err() != nil, andresultis still nil if cancellation happens before the first entry is appended.The caller then does:
So on an early cancellation the handler returns without writing anything, short-circuiting before the
ctx.Err()check that would otherwise callclientCanceledResponse— the client sees a 200 with no body.The nil sentinel is overloaded: it means both "already responded" and "no entries yet". Splitting those (an explicit
responded bool, or a sentinel error) would fix it.Originally raised by CodeRabbit on #1317; I verified it is pre-existing on
mainand not introduced by that PR, so it belongs here rather than as a change request on the stack.