fix: include transitDetails in Routes API field mask#81
Merged
Conversation
COMPUTE_ROUTES_FIELD_MASK was missing routes.legs.steps.transitDetails,
so transit steps only returned a free-text navigationInstruction
("Bus towards X") without structured metadata (bus number, stop names,
headsign, agency). Google Routes API only returns this object when
explicitly requested via X-Goog-FieldMask.
Adds the field to the mask — additive only, no impact on driving/walking
responses (the field is absent in non-transit steps anyway).
Adds a smoke test using Dublin Airport -> Trinity College Dublin, which
virtually always returns a bus step. The test asserts that at least one
step contains transitDetails with transitLine/stopDetails; if Google
returns a walking-only itinerary, the test warns and skips rather than
flaky-failing.
CI runs format:check on every PR; this is the first PR to trigger it since the workflow was added. The avoid_tolls one-liner in three route tools (introduced in #80) and a long console.log line in the new transit test both exceeded prettier's print-width and are split to match the existing avoid_highways formatting. No semantic changes.
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.
Summary
Closes #78
The
COMPUTE_ROUTES_FIELD_MASKinsrc/services/RoutesService.tswas missingroutes.legs.steps.transitDetails, so transit steps returned only a free-textnavigationInstruction.instructions(e.g."Bus towards Sean Moore Rd") without structured metadata — bus/route number, stop names, headsign, agency, stop count. Google Routes API only returns this object when explicitly requested via theX-Goog-FieldMaskheader.This also resolves the symptom reported in #74 (comment) — "transit directions tell you to take a bus, but doesn't describe which one" — which shares the same root cause.
Changes
src/services/RoutesService.tsroutes.legs.steps.transitDetailstoCOMPUTE_ROUTES_FIELD_MASKtests/smoke.test.tstestTransitDetailsField: assert transit step containstransitDetailswithtransitLine/stopDetailsImpact
PlacesSearcher.getDirectionsalready passesroutesthrough verbatim;maps_directionsACTIONdoesJSON.stringify(result.data), so the new object flows through untouched.computeRouteMatrix(distance matrix) — its field mask has nostepslevel.Test plan
npm run buildsucceedsnpm run lint— 0 errors (175 pre-existing warnings unchanged)npm test— 198 passed, 0 failedtransitDetails.{stopDetails, transitLine, headsign, stopCount, localizedValues}Root cause verification
Independently called the Routes API with the new field mask:
The same field mask addition also restores structured transit metadata for Harold's Cross → Rathmines (the exact route in #78) and Paris → Lyon.