Skip to content

Fix/route agency db error#793

Open
FLASH2332 wants to merge 2 commits intoOneBusAway:mainfrom
FLASH2332:fix/route-agency-db-error
Open

Fix/route agency db error#793
FLASH2332 wants to merge 2 commits intoOneBusAway:mainfrom
FLASH2332:fix/route-agency-db-error

Conversation

@FLASH2332
Copy link
Contributor

Problem:
In routeHandler, the error returned by GetAgency was silently discarded:
goagency, err := api.GtfsManager.GtfsDB.Queries.GetAgency(ctx, agencyID)

if err == nil { // agency added to references } // any error is silently dropped 

If this DB call failed for any reason — including context.Canceled or context.DeadlineExceeded — the handler would skip the agency reference and return a successful response with incomplete data.

Fix :
sql.ErrNoRows → agency reference is optional, skip silently and continue
Any other error → route through serverErrorResponse, which correctly handles context cancellation and deadline exceeded

Changes :
internal/restapi/route_handler.go — added explicit error handling for GetAgency

Closes #792

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

Labels

None yet

1 participant