Skip to content

fix: include transitDetails in Routes API field mask#81

Merged
cablate merged 2 commits into
mainfrom
fix/transit-details-field-mask
Jul 3, 2026
Merged

fix: include transitDetails in Routes API field mask#81
cablate merged 2 commits into
mainfrom
fix/transit-details-field-mask

Conversation

@cablate

@cablate cablate commented Jul 3, 2026

Copy link
Copy Markdown
Owner

Summary

Closes #78

The COMPUTE_ROUTES_FIELD_MASK in src/services/RoutesService.ts was missing routes.legs.steps.transitDetails, so transit steps returned only a free-text navigationInstruction.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 the X-Goog-FieldMask header.

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

File Change
src/services/RoutesService.ts Add routes.legs.steps.transitDetails to COMPUTE_ROUTES_FIELD_MASK
tests/smoke.test.ts New testTransitDetailsField: assert transit step contains transitDetails with transitLine/stopDetails

Impact

  • Additive only. The field is absent in non-transit steps, so driving/walking/bicycling responses are unchanged.
  • No schema or call-site changes. PlacesSearcher.getDirections already passes routes through verbatim; maps_directions ACTION does JSON.stringify(result.data), so the new object flows through untouched.
  • No effect on computeRouteMatrix (distance matrix) — its field mask has no steps level.

Test plan

  • npm run build succeeds
  • npm run lint — 0 errors (175 pre-existing warnings unchanged)
  • npm test198 passed, 0 failed
  • Verified live API response: Dublin Airport → Trinity College Dublin returns a bus step with transitDetails.{stopDetails, transitLine, headsign, stopCount, localizedValues}

Root cause verification

Independently called the Routes API with the new field mask:

Dublin Airport -> Trinity College Dublin: step[0] "Bus towards Dublin Airport Stops"
  transitDetails keys: stopDetails, localizedValues, headsign, transitLine, stopCount

The same field mask addition also restores structured transit metadata for Harold's Cross → Rathmines (the exact route in #78) and Paris → Lyon.

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.
@cablate cablate merged commit 9d4e4e2 into main Jul 3, 2026
1 check passed
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.

maps_directions: Transit mode missing bus/route details (transitDetails not in field mask)

1 participant