Fix swallowed duplicated trip lookup errors - #1378
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository UI Review profile: ASSERTIVE Plan: Pro Plus Run ID: 📒 Files selected for processing (2)
Included review availability: Your plan provides up to 1 included review per hour; 0 remain after this review. 📝 WalkthroughWalkthroughThe DUPLICATED trip resolver now returns non-not-found database errors. The trips-for-route handler responds with HTTP 500 for those errors. Tests cover direct lookup failure, stripped-ID lookup failure, and successful suffix fallback resolution. ChangesDUPLICATED trip error handling
Estimated code review effort: 3 (Moderate) | ~20 minutes Merge Risk: ⚪ Minimal · up to Unexpected database failures now return the endpoint’s existing generic HTTP 500 response instead of being treated as missing data, while valid fallback lookups continue to succeed. No actionable merge-blocking risk remains after normal checks and review. Sequence Diagram(s)sequenceDiagram
participant TripsForRouteHandler
participant resolveDuplicatedBaseTrip
participant GTFSDatabase
participant serverErrorResponse
TripsForRouteHandler->>resolveDuplicatedBaseTrip: Resolve duplicated trip ID
resolveDuplicatedBaseTrip->>GTFSDatabase: GetTrip full or stripped ID
GTFSDatabase-->>resolveDuplicatedBaseTrip: Return trip, not found, or database error
resolveDuplicatedBaseTrip-->>TripsForRouteHandler: Return resolved trip or error
TripsForRouteHandler->>serverErrorResponse: Send HTTP 500 for database error
Suggested reviewers: 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
Full details: Linked Issues checkExplanation The changes satisfy issue
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
Thanks, I am working on resolving the merge conflicts now. I will push the updated changes once they are resolved. |
|
|
Merge conflicts have been resolved and all CI checks are passing. I also verified the changes locally. |



Description
Fixes #1366.
When resolving a
DUPLICATEDtrip,sql.ErrNoRowsis expected and allows the handler to fall back to the stripped trip ID. However, other database errors were being treated like a not-found result.This change propagates unexpected database errors from both the direct and fallback trip lookups so the endpoint returns HTTP 500 instead of silently continuing.
Tests
go test -tags "purego" ./internal/restapi/...go vet -tags "purego" ./...git diff --checkSummary by CodeRabbit