fix: implement vehicleId query parameter in trip-details#1061
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
📝 WalkthroughWalkthroughAdds support for the ChangesVehicle ID parameter support
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Suggested reviewers
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
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 |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@internal/restapi/trip_details_handler.go`:
- Around line 161-169: The code extracts agency and rawVehicleID from
params.VehicleID via utils.ExtractAgencyIDAndCodeID but never validates the
extracted agency; update the handling in the block that calls params.VehicleID
so that after extracting agencyID and rawVehicleID you compare the extracted
agencyID to the trip's agency (e.g. trip.AgencyID) and if they differ call
api.sendNotFound(w, r) and return; only when agencies match proceed to call
api.GtfsManager.GetVehicleByID(rawVehicleID) and the existing nil/error checks.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro Plus
Run ID: 40fd7c4d-3482-4535-9614-733f70cc416e
📒 Files selected for processing (2)
internal/restapi/trip_details_handler.gointernal/restapi/trip_details_handler_test.go
|



Description
This PR addresses (spec gap) by implementing support for the
vehicleIdquery parameter in thetrip-detailsendpoint.Previously, the endpoint ignored this parameter entirely. Per the wiki spec, when
vehicleIdis provided, the endpoint must filter the results to only consider the block instance currently assigned to that specific vehicle.Changes Included:
TripParamsandparseTripParamsto explicitly extract thevehicleIdfrom the URL query.tripDetailsHandlerto extract the raw entity ID and verify the vehicle's existence viaGtfsManager.GetVehicleByID().*gtfs.VehicleintoBuildTripStatusinstead of passingnil.trip_details_handler_test.goverifying valid, unknown, and malformedvehicleIdinputs.fixes: #1052
Summary by CodeRabbit
New Features
Bug Fixes
Tests