Show OTP2 walk route instead of a "try walking instead" advisory (#1947)#1959
Merged
Conversation
…1947) OTP2 always computes a direct WALK itinerary alongside transit (the planConnection modes default is "all transit modes + WALK for direct street suggestions"). When that walk's generalized cost — which folds in wait/transfer/boarding penalties, not just distance — beats every transit option, OTP's filter chain deletes the transit itineraries, attaches WALKING_BETTER_THAN_TRANSIT, and keeps the walk-only itinerary in the response. Otp2Planner.plan checked routingErrors before the itineraries, so it threw that advisory and discarded the valid walk route sitting in the same payload — surfacing "Try walking instead" with no result, even for trips far too long to actually walk. Extract resolveOtp2Plan(), which makes itineraries win over routing errors: return any itineraries present, and only classify a routing error when edges is empty. Fatal codes (LOCATION_NOT_FOUND, OUTSIDE_BOUNDS, NO_TRANSIT_CONNECTION, the same-location advisory from SameEdgeAdjuster) always arrive with empty edges, so they still classify exactly as before. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
|
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 (2)
📝 WalkthroughWalkthroughOTP2 planning now prioritizes returned itineraries over routing errors. Response resolution is extracted into a helper, with tests covering walk itineraries, advisory and fatal errors, and no-route responses. ChangesOTP2 plan resolution
Estimated code review effort: 3 (Moderate) | ~20 minutes Possibly related issues
Possibly related PRs
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
Fixes the "plain bug" in #1947: the trip planner shows a "Try walking instead" advisory (and no route) even for trips far too long to actually walk.
Root cause — a client ordering bug, not an OTP bug
When the app sends a transit request, OTP2 also computes a direct WALK itinerary — the
planConnection.modesdefault is documented as "all transit modes are usable and WALK is used for direct street suggestions." When that walk's generalized cost beats every transit option, OTP's filter chain (RemoveTransitIfWalkingIsBetter→RoutingErrorsAttacher) deletes the transit itineraries, attachesWALKING_BETTER_THAN_TRANSIT, and keeps the walk-only itinerary inplanConnection.edges.Two notes on the "you clearly can't walk" reports:
SameEdgeAdjusterpath (origin == destination), which returns no itineraries.Otp2Planner.plancheckedroutingErrorsbefore the itineraries, so it threw the advisory and discarded the valid walk route in the same payload.Fix
Extract
resolveOtp2Plan(), which makes itineraries win over routing errors: return any itineraries present, and only classify a routing error whenedgesis empty. This shows OTP's walk route as a normal result. It's safe for every fatal code (LOCATION_NOT_FOUND,OUTSIDE_BOUNDS,NO_TRANSIT_CONNECTION, the same-location advisory) because those always arrive with emptyedges, so they still classify exactly as before.Tests
New
Otp2PlanResolveTest(4 cases): walk-itinerary-wins (the regression), empty-edges advisory, fatal error still surfaces, and no-route. Compiles clean under-PwarningsAsErrors=true; new + existing decode/error-mapping tests pass.Scope
This is the "defend against the bug" half of #1947. The issue also asks to eventually drop the advisory string entirely and proactively request walk-only itineraries for the genuinely-empty case — left as follow-on. The advisory now only appears in the degenerate origin == destination case.
🤖 Generated with Claude Code
Summary by CodeRabbit
Bug Fixes
Tests