Skip to content

trips-for-location returns 200 with no body when the client cancels early #1324

Description

@aaronbrethorst

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.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions