Skip to content

Fix/trip for vehicle include references - #1281

Open
Ahmedhossamdev wants to merge 3 commits into
mainfrom
fix/trip-for-vehicle-include-references
Open

Fix/trip for vehicle include references#1281
Ahmedhossamdev wants to merge 3 commits into
mainfrom
fix/trip-for-vehicle-include-references

Conversation

@Ahmedhossamdev

@Ahmedhossamdev Ahmedhossamdev commented Aug 2, 2026

Copy link
Copy Markdown
Member

Fixes: #1280

Summary by CodeRabbit

  • Bug Fixes
    • Trip-for-vehicle responses now correctly omit agency, route, trip, and stop references when reference inclusion is disabled.
    • Trip entries remain available even when references are excluded.

The spec omits the references block when includeReferences=false, and the
reference server returns every reference array empty for that request.
trip-for-vehicle ignored the parameter and returned a fully populated
block, so callers asking to skip references still paid for the stop,
route and trip lookups behind them.

Gate the reference building on the existing ShouldIncludeReferences
helper, already used by stop and routes-for-agency, and follow the same
convention of leaving the block present but empty rather than dropping
the key.

Extract the building itself into buildTripForVehicleReferences so the
guard does not indent sixty lines of the handler, and so the handler
reads as the sequence of steps it performs.
@coderabbitai

coderabbitai Bot commented Aug 2, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Warning

Review limit reached

@Ahmedhossamdev, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 51 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

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 reviews.

How do review 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 refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: Repository UI

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: a51b0a0c-5481-4071-822f-493dc1b5fadf

📥 Commits

Reviewing files that changed from the base of the PR and between acfad51 and 63275db.

📒 Files selected for processing (1)
  • internal/restapi/trip_for_vehicle_handler_test.go
📝 Walkthrough

Walkthrough

The trip-for-vehicle handler now conditionally builds references. When includeReferences=false, it preserves the trip entry and returns empty reference collections. Reference construction now returns errors to the handler.

Changes

Trip reference handling

Layer / File(s) Summary
Conditional reference construction
internal/restapi/trip_for_vehicle_handler.go
The handler initializes empty references and calls buildTripForVehicleReferences only when references are requested. The helper builds agency, stop, route, and optional trip references, then returns errors to the handler.
Disabled reference coverage
internal/restapi/trip_for_vehicle_handler_test.go
The end-to-end test verifies that the trip entry remains populated and all reference collections are empty when includeReferences=false.

Estimated code review effort: 2 (Simple) | ~10 minutes

Possibly related PRs

Suggested reviewers: burma-shave

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly identifies the fix for trip-for-vehicle reference handling.
Linked Issues check ✅ Passed The changes call ShouldIncludeReferences, skip reference building when false, and preserve an empty references block as required by issue #1280.
Out of Scope Changes check ✅ Passed The handler refactor and end-to-end test directly support the linked issue and introduce no unrelated changes.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@github-actions

github-actions Bot commented Aug 2, 2026

Copy link
Copy Markdown

Performance Smoke Test Results

Status: PASSED

Metric Value
p(95) latency 2.2 ms
Error rate 0.00%
Total requests 341
Req/sec 11.1

Smoke test config: 5 VUs x 30s. Thresholds: p(95) < 300ms, error rate < 1%.

Full results uploaded as workflow artifact: k6-smoke-summary.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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_for_vehicle_handler_test.go`:
- Around line 179-190: Update the “includeReferences=false empties the
references block” test to assert the handler responds with HTTP 200, then
require all reference collections—including Situations and StopTimes—to be
non-nil while remaining empty. Preserve the existing TripID assertion and checks
for Agencies, Routes, Trips, and Stops.
🪄 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: Repository UI

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: 1f6910ed-5bc8-441d-960c-89a32bcea679

📥 Commits

Reviewing files that changed from the base of the PR and between 3b73fd9 and acfad51.

📒 Files selected for processing (2)
  • internal/restapi/trip_for_vehicle_handler.go
  • internal/restapi/trip_for_vehicle_handler_test.go

Comment thread internal/restapi/trip_for_vehicle_handler_test.go
The includeReferences=false test discarded the response, so a 429 from
the shared rate limiter would have satisfied every assertion in it: the
error envelope carries no references at all, and assert.Empty is happy
with nil. Require a 200 first.

Also require each collection to be non-nil as well as empty, and cover
situations and stopTimes alongside the four the handler populates. The
block is meant to stay present and merely empty, so these assertions pin
the wire format to [] rather than null for every collection, including
the two nothing in this handler touches.
@sonarqubecloud

sonarqubecloud Bot commented Aug 2, 2026

Copy link
Copy Markdown

@github-actions

github-actions Bot commented Aug 2, 2026

Copy link
Copy Markdown

Performance Smoke Test Results

Status: PASSED

Metric Value
p(95) latency 2.1 ms
Error rate 0.00%
Total requests 336
Req/sec 11.0

Smoke test config: 5 VUs x 30s. Thresholds: p(95) < 300ms, error rate < 1%.

Full results uploaded as workflow artifact: k6-smoke-summary.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

trip-for-vehicle: honour includeReferences=false

1 participant