Skip to content

route-handler: DB error fetching agency reference data is silently ignored #792

@FLASH2332

Description

@FLASH2332

Problem :

In routeHandler, the error returned by GetAgency is silently discarded:

agency, err := api.GtfsManager.GtfsDB.Queries.GetAgency(ctx, agencyID)
if err == nil {
    // agency added to references
}
// any error, including context.Canceled / context.DeadlineExceeded, is silently dropped

If this DB call fails for any reason — including context.Canceled or context.DeadlineExceeded — the handler skips the agency reference and returns a successful response with incomplete data. Context errors in particular should never be silently ignored.
Expected Behavior

sql.ErrNoRows → agency reference is optional, skip silently and continue
Any other error → route through serverErrorResponse, which already handles context cancellation and deadline exceeded correctly (see internal/restapi/errors.go)

internal/restapi/errors.go — existing pattern that should be used:

if errors.Is(err, context.Canceled) || errors.Is(err, context.DeadlineExceeded) {
    api.clientCanceledResponse(w, r, err)
    return
}

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