fix(search): encode cabin class in tfs booking deep-links - #231
Open
Fanfulla wants to merge 1 commit into
Open
Conversation
build_tfs_token hardcoded protobuf field 9 to economy (1), so booking URLs from a business/first search opened the economy page. Pass SeatType through the encoder, CLI, MCP, and JS port. Default remains economy so captured golden tokens stay byte-equal. Closes punitarani#213
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
build_tfs_tokenalways writes protobuf field 9 as1(economy). Booking URLs built after a premium/business/first search therefore open the economy booking page.Reproduced on current main by decoding a generated
tfstoken: the wire bytes contain0x40 0x01 0x48 0x01 0x70 0x01(f8=1, f9=1, f14=1) regardless of the cabin used for the search. The same hardcode exists in the JS port.Fixes #213.
Cause
Field 9 is the seat-class slot (
1economy,2premium,3business,4first), matchingSeatType. The encoder never took a cabin argument, and neither the CLI nor the MCP server passed the search'sseat_typeintobuild_flight_booking_url.Change
build_tfs_token(..., seat=1)writes field 9 fromseat. Default remains economy so captured golden tokens stay byte-equal.SearchFlights.build_flight_booking_url(..., seat_type=SeatType.ECONOMY)forwardsseat_type.value.flightsand MCPsearch_flights/get_booking_optionspass the search cabin through.buildTfsToken({ seat }),buildFlightBookingUrl({ seatType })).Passenger count is still hardcoded (field 8). That is a nested message and is out of scope here, as noted in #213.
Tests
Executed locally:
uv run pytest -vv tests/search/test_proto.py tests/search/test_booking_url.py tests/cli/test_flights.py— 74 passeduv run pytest -q tests/search/test_proto.py::TestBuildTfsToken::test_seat_business_encodes_field_9 tests/search/test_booking_url.py::TestBuildFlightBookingUrl::test_seat_type_business_changes_tfs_field_9 tests/cli/test_flights.py::test_flights_with_cabin_class— 3 passed1made the two new encoder tests fail; restoring the fix made them passuv run ruff check/ruff format --checkon the touched Python files — cleanbun test tests/search/proto.test.ts tests/search/flights_booking_url.test.ts— 55 passedbun run typecheck— cleanGolden
tfsfixtures (economy captures) remain byte-perfect.Greptile Summary
This PR propagates the selected cabin class into deterministic Google Flights booking deep links while preserving economy as the backward-compatible default.
tfstoken builders.Confidence Score: 5/5
The PR appears safe to merge, with cabin values consistently propagated through the affected booking-link paths.
The supported cabin enums map to the expected numeric values, all repository booking-link adapters forward the search cabin, defaults preserve existing economy tokens, and no changed-code failure remains.
Important Files Changed
Flowchart
%%{init: {'theme': 'neutral'}}%% flowchart LR A[CLI, MCP, or SDK caller] --> B[Typed cabin selection] B --> C[Booking URL builder] C --> D[Pass SeatType numeric value] D --> E[tfs protobuf encoder] E --> F[Field 9: cabin class] F --> G[Google Flights booking deep link]Reviews (1): Last reviewed commit: "fix(search): encode cabin class in tfs b..." | Re-trigger Greptile
Context used (4)