fix: include outOfRange field in vehicles-for-agency response#1114
fix: include outOfRange field in vehicles-for-agency response#11143rabiii wants to merge 2 commits into
Conversation
Switched from NewListResponse to NewListResponseWithRange to ensure the outOfRange boolean is properly emitted in the response envelope's data object, fulfilling minimal guarantee requirements. Since Maglev currently operates as a single-instance server covering its entire configured database, outOfRange is hardcoded to false for both known agencies and unknown/untracked agencies (Extension 3a). Added corresponding test assertions.
|
Warning Review limit reached
More reviews will be available in 33 minutes and 59 seconds. Learn how PR review limits work. Your organization has used up its prepaid credits, and credit purchases are no longer available. Enable the review add-on in the billing tab to keep reviews running — you're only billed for reviews past your plan's rate limits ($0.25/file). ⌛ How to resolve this issue?After more reviews become available, a review can be triggered using the To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based credits. 🚦 How do rate limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability. For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window. Please see our Fair Usage Limits Policy for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (1)
📝 WalkthroughWalkthroughThe Vehicles-for-agency outOfRange field
Estimated code review effort🎯 1 (Trivial) | ⏱️ ~3 minutes Possibly related PRs
Suggested reviewers
🚥 Pre-merge checks | ✅ 3 | ❌ 2❌ Failed checks (2 warnings)
✅ Passed checks (3 passed)
✨ 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/vehicles_for_agency_handler_test.go`:
- Around line 72-85: The current assertions in TestVehiclesForAgencyHandler and
TestVehiclesForAgencyHandler_OutOfRangeFalseForKnownAgency only check the
decoded bool, so they won’t fail if data.outOfRange is missing from the JSON.
Update these tests to inspect the raw response payload (or decode the data
object into a map/json.RawMessage) and assert that the outOfRange field is
actually present before verifying it is false; keep using the existing helpers
like callAPIHandler and the VehiclesForAgencyResponse path to locate the check.
🪄 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: 0ced07b4-e657-49c3-8d83-5fab3e257504
📒 Files selected for processing (2)
internal/restapi/vehicles_for_agency_handler.gointernal/restapi/vehicles_for_agency_handler_test.go
Update tests to parse the raw JSON message instead of decoding directly into a struct. This prevents Go's boolean zero-value from creating false-positive assertions when the field is omitted.
|



Summary
Fixes a spec gap where the
vehicles-for-agencyendpoint was missing theoutOfRangeboolean field in the response envelope'sdataobject.Problem
The spec mandates that the
dataobject must contain anoutOfRangeboolean to help clients distinguish between agencies that are simply unknown and those that are outside the server's service area. The previous implementation usedmodels.NewListResponse, which completely omitted this field from the JSON output.Changes
models.NewListResponseWithRange(...).outOfRange: falsein the success path.outOfRange: falsealongside the empty list whenagency == nil.outOfRange: true) is not currently applicable. The key fix is ensuring the field is consistently present in the payload.outOfRange == falsefor both known and non-existent agencies.Closes #1113
Summary by CodeRabbit
Bug Fixes
outOfRangeasfalsein these cases.Tests
outOfRangefield in vehicles-for-agency responses.