Google Flights MCP, CLI and Python Library
fix(search): restore search via the public page's tfs parameter (#223) (#230)
Prince Upadhyay5c092f12e10d
diff --git a/CLAUDE.md b/CLAUDE.mdindex 4385ada..79b6c2d 100644--- a/CLAUDE.md+++ b/CLAUDE.md@@ -93,6 +93,53 @@ uv run mkdocs build # Build static docs- **Shared Utilities**: Core parsing/building logic shared between CLI and MCP- **Validation**: Pydantic models ensure data integrity throughout+## Search transport++Searches go through Google's public search page, not the+`FlightsFrontendService` RPC. Since 2026-08 `GetShoppingResults` and+`GetCalendarGraph` require an `x-goog-batchexecute-bgr` header that only the+page's JavaScript can produce, so the client issues+`GET https://www.google.com/travel/flights?tfs=<protobuf>` and reads the+`AF_initDataCallback` blob keyed `ds:1`. Request encoding lives in+`fli/search/_tfs.py` and `fli/search/_proto.py`.++Consequences to keep in mind when changing search code:++- `emissions`, `bags` and `exclude_basic_economy` have no `tfs` field and no+ post-hoc equivalent; `unsupported_filters()` names them and the caller warns.+- Airline include/exclude, price cap, max duration and departure windows are+ applied after fetching by `apply_client_side_filters()`; stops, cabin,+ passengers, alliances and layover bounds are encoded into the request.+- Multi-city raises `SearchUnsupportedError` — the page inlines no rows for it.+- `get_booking_options` hits `GetBookingResults`, which is still gated, so it+ currently raises `SearchRejectedError`. Booking deep links (`tfs`) are built+ offline and unaffected.+- A search returns fewer rows than the old RPC (~20-45), and client-side+ filtering is not back-filled.+- Date searches have no calendar grid: one page fetch per date, capped at+ `fli.search.dates.MAX_DATES_PER_SEARCH` (93) per `SearchDates.search`. At the+ cap that is several hundred MB of pages and parsed JSON at peak.+- `_SweepHealth` (`SWEEP_FAILURE_THRESHOLD`, 5) is the sweep's circuit breaker.+ It counts **only** payload-less pages — that failure is deterministic, so the+ untried dates will fail the same way; a timeout or connection error says+ nothing about them and deliberately does not count. It is armed only while no+ date has loaded a page and disarmed permanently by the first success, so a+ working sweep keeps the full retry budget for transient misses.+ Measured with the real backoff, it turns a fully blocked 93-date sweep from+ 279 page fetches (up to 837 HTTP requests once the client's own retries+ multiply) into 42 in ~4s, bounded at+ (threshold + pool workers) x `PAGE_FETCH_ATTEMPTS` = 45 regardless of range —+ the bound scales with `configure_concurrency`.+ When it trips but prices still come back, `_collect` emits exactly one+ warning naming the skipped count: a truncated answer must never be silent.+- ~1 page in 60 arrives HTTP 200 with no `ds:1` blob. `fetch_payload` in+ `fli/search/_tfs.py` is the single fetch path for both flights and dates and+ retries exactly that case (`PAGE_FETCH_ATTEMPTS`, `PAGE_RETRY_BACKOFF`);+ HTTP errors and error-13 rejections are not retried there.+- `FLI_SOCS_COOKIE` overrides the pre-accepted `SOCS` consent cookie the client+ sends so EU/EEA IPs skip Google's consent interstitial; set it empty to send+ no cookie.+## Key Files and Entry Points- `fli/cli/main.py` - CLI entry point and command registration@@ -150,6 +197,11 @@ Find cheapest travel dates within a range.Flights for that specific date (and return date for round trips).### `get_booking_options`+**Currently unavailable:** it calls `GetBookingResults`, which is gated behind+the browser-signed header (see "Search transport"), so it raises+`SearchRejectedError`. Use a flight's `booking_url` deep link instead. The rest+of this section describes the tool for when that RPC becomes reachable again.+Get bookable fares (vendor names, prices, and direct booking URLs) for asingle itinerary. Runs a fresh search, selects the flight identified by`flight_numbers` (or the top result when omitted), then calls@@ -185,10 +237,14 @@ one-line `Error: ...` and a non-zero exit code; the MCP tools surfaceother validators).### Note on emissions-Both tools accept the `emissions` filter (forwarded to Google's-"less emissions" toggle as `LESS`), but raw CO₂ figures are intentionally-**not** returned in CLI output or MCP tool responses. The filter operates-server-side; the data is not displayed in the current release.+The API surface still accepts the `emissions` filter, but the search-page+transport has no `tfs` field for it, so it is **currently ignored** — the+search logs a warning naming it and returns unfiltered results. The same is+true of `checked_bags` / `carry_on` and `exclude_basic_economy`. See+"Search transport" above.++Independently of that: raw CO₂ figures are intentionally **not** returned in+CLI output or MCP tool responses, and that is unchanged.## Releasingdiff --git a/README.md b/README.mdindex 0bafe4b..0f4a740 100644--- a/README.md+++ b/README.md@@ -157,6 +157,56 @@ fli --help* Comprehensive error handling* Input validation+## Search transport++Searches are served by Google's public search page rather than the+`FlightsFrontendService` RPC. Since 2026-08 `GetShoppingResults` and+`GetCalendarGraph` require an `x-goog-batchexecute-bgr` header that only the+page's own JavaScript can produce, so a plain HTTP client gets HTTP 200 with no+payload. Fli issues `GET https://www.google.com/travel/flights?tfs=<protobuf>`+instead and reads the results out of the page's inline `AF_initDataCallback`+blob keyed `ds:1`.++What that means in practice:++* **Three filters are not supported.** `emissions`, `bags` and+ `exclude_basic_economy` have no `tfs` field and cannot be reconstructed from+ the decoded rows, so they are dropped with a warning. Stops, cabin,+ passengers, alliances and layover bounds ride in the request; airline+ include/exclude, price cap, max duration and departure windows are applied to+ the results after fetching.+* **Multi-city raises `SearchUnsupportedError`.** Google loads those results+ client-side through the gated RPC, so the page carries no rows to read.+ Search each leg separately.+* **`get_booking_options` is unavailable.** It calls `GetBookingResults`, which+ is gated the same way, and currently raises `SearchRejectedError`. The+ per-flight `tfs` booking deep links are built offline and still work.+* **Fewer rows per search.** Expect roughly 20-45 itineraries, fewer than the+ old RPC returned — and a client-side filter cannot back-fill the list the way+ Google's server-side one did.+* **Date searches cost one page fetch per date.** The page has no calendar+ grid, so a range is priced date by date; one `SearchDates.search` covers at+ most 93 dates and a wider range raises `ValueError`. Budget for it: 93 dates+ across 10 workers is several hundred MB of pages and parsed JSON at peak.+ A sweep that never manages to load a single page — the shape a blocked or+ consent-gated client produces — gives up after a handful of dates rather than+ paying the retry budget on all of them. Only pages served without results+ count towards that: a timeout or a dropped connection says nothing about the+ dates not yet tried, so those never abandon a sweep. Measured with the real backoff: **42+ page fetches** (bounded at 45, so up to ~135 HTTP requests once the client's+ own retries multiply in) and about 4 seconds, the same whether the range is 30+ days or 93. Unbroken, a 93-date range would have cost 279 fetches and up to+ 837 requests. The bound is `(5 + worker count) x 3`, so raising+ `configure_concurrency` raises it proportionally.+* **A page occasionally arrives without results.** Roughly one request in sixty+ returns HTTP 200 with no `ds:1` blob; the client retries that case up to twice+ (0.5s then 1.5s) before raising `SearchParseError`. A healthy search never+ pays for it.+* **`FLI_SOCS_COOKIE`.** EU/EEA IPs are redirected to Google's consent+ interstitial, which serves no `ds:1` blob. The client sends a pre-accepted+ `SOCS` consent cookie by default; set `FLI_SOCS_COOKIE` to change the value,+ or to an empty string to send none.+## CLI Usage### Search for Flightsdiff --git a/docs/guides/mcp.md b/docs/guides/mcp.mdindex 6ff72ca..009585c 100644--- a/docs/guides/mcp.md+++ b/docs/guides/mcp.md@@ -227,15 +227,15 @@ find out where (and at what price) a specific flight can be booked.| `infants_in_seat` | int | No | 0 | Number of infants (under 2) occupying their own seat || `infants_on_lap` | int | No | 0 | Number of lap infants (under 2, no seat) — cannot exceed `passengers` || `airlines` | list | No | null | Filter by airline codes (e.g., ['BA', 'AA']) |-| `exclude_basic_economy` | bool | No | false | Exclude basic economy fares |+| `exclude_basic_economy` | bool | No | false | Exclude basic economy fares. **Currently ignored by the search transport** (logged as a warning). || `departure_window` | string | No | null | Time window in 'HH-HH' format (e.g., '6-20') || `sort_by` | string | No | CHEAPEST | Sort order — matters when `flight_numbers` is omitted || `exclude_airlines` | list | No | null | Airline IATA codes to **exclude** || `alliance` / `exclude_alliance` | list | No | null | Restrict / exclude ONEWORLD, SKYTEAM, STAR_ALLIANCE || `min_layover` / `max_layover` | int | No | null | Layover duration bounds (minutes) |-| `emissions` | string | No | ALL | ALL or LESS |-| `checked_bags` | int | No | 0 | Checked bags included in price (0–2) |-| `carry_on` | bool | No | false | Include carry-on bag fee in price |+| `emissions` | string | No | ALL | ALL or LESS. **Currently ignored by the search transport** (logged as a warning). |+| `checked_bags` | int | No | 0 | Checked bags included in price (0–2). **Currently ignored by the search transport** (logged as a warning). |+| `carry_on` | bool | No | false | Include carry-on bag fee in price. **Currently ignored by the search transport** (logged as a warning). || `currency` | string | No | null | ISO 4217 currency code (`curr=`) || `language` | string | No | null | BCP-47 language code (`hl=`) || `country` | string | No | null | ISO 3166-1 alpha-2 country (`gl=`) |diff --git a/fli/cli/commands/dates.py b/fli/cli/commands/dates.pyindex f28cd23..4c30241 100644--- a/fli/cli/commands/dates.py+++ b/fli/cli/commands/dates.py@@ -36,6 +36,7 @@ from fli.models import (TripType,)from fli.search import SearchClientError, SearchDates+from fli.search.dates import MAX_DATES_PER_SEARCHdef _build_selected_days(@@ -74,9 +75,13 @@ def dates(str,typer.Option("--from", help="Start date (YYYY-MM-DD)"),] = (datetime.now() + timedelta(days=1)).strftime("%Y-%m-%d"),- end_date: Annotated[str, typer.Option("--to", help="End date (YYYY-MM-DD)")] = (- datetime.now() + timedelta(days=60)- ).strftime("%Y-%m-%d"),+ end_date: Annotated[+ str,+ typer.Option(+ "--to",+ help=(f"End date (YYYY-MM-DD); at most {MAX_DATES_PER_SEARCH} dates per search"),+ ),+ ] = (datetime.now() + timedelta(days=60)).strftime("%Y-%m-%d"),trip_duration: Annotated[int,typer.Option(diff --git a/fli/cli/commands/flights.py b/fli/cli/commands/flights.pyindex bd84bb6..7bf2cf4 100644--- a/fli/cli/commands/flights.py+++ b/fli/cli/commands/flights.py@@ -385,7 +385,7 @@ def flights(typer.Option("--exclude-basic","-e",- help="Exclude basic economy fares",+ help="Exclude basic economy fares. [currently ignored by the search transport]",),] = False,layover: Annotated[@@ -400,7 +400,9 @@ def flights(str,typer.Option("--emissions",- help="Filter by emissions level (ALL, LESS)",+ help=(+ "Filter by emissions level (ALL, LESS). [currently ignored by the search transport]"+ ),),] = "ALL",checked_bags: Annotated[@@ -408,7 +410,10 @@ def flights(typer.Option("--bags","-b",- help="Number of checked bags to include in price (0, 1, or 2)",+ help=(+ "Checked bags included in price (0, 1, or 2). "+ "[currently ignored by the search transport]"+ ),min=0,max=2,),@@ -417,7 +422,7 @@ def flights(bool,typer.Option("--carry-on",- help="Include carry-on bag fee in price",+ help="Include carry-on bag fee in price. [currently ignored by the search transport]",),] = False,all_results: Annotated[diff --git a/fli/cli/errors.py b/fli/cli/errors.pyindex e6f7f53..f96dcdd 100644--- a/fli/cli/errors.py+++ b/fli/cli/errors.py@@ -20,6 +20,8 @@ from fli.search.exceptions import (SearchClientError,SearchConnectionError,SearchHTTPError,+ SearchParseError,+ SearchRejectedError,SearchTimeoutError,)@@ -35,6 +37,14 @@ def _friendly_message(exc: BaseException) -> str:return f"Network error. {exc}"if isinstance(exc, SearchHTTPError):return f"Google Flights error. {exc}"+ if isinstance(exc, SearchRejectedError):+ return f"Google Flights declined the request. {exc}"+ if isinstance(exc, SearchParseError):+ return (+ f"Could not read Google Flights' response. {exc} "+ "This is usually a transient page variant or a regional consent "+ "interstitial — retry, or set FLI_SOCS_COOKIE if you are in the EU/EEA."+ )if isinstance(exc, SearchClientError):return f"Search failed. {exc}"return f"Unexpected error: {exc.__class__.__name__}: {exc}"@@ -96,6 +106,10 @@ def json_error_payload(exc: BaseException, *, command: str | None = None) -> tupreturn str(exc), "connection_error", log_pathif isinstance(exc, SearchHTTPError):return str(exc), "http_error", log_path+ if isinstance(exc, SearchRejectedError):+ return str(exc), "rejected", log_path+ if isinstance(exc, SearchParseError):+ return str(exc), "parse_error", log_pathif isinstance(exc, SearchClientError):return str(exc), "search_error", log_pathreturn f"{exc.__class__.__name__}: {exc}", "unexpected_error", log_pathdiff --git a/fli/mcp/server.py b/fli/mcp/server.pyindex 82621c4..280e584 100755--- a/fli/mcp/server.py+++ b/fli/mcp/server.py@@ -43,6 +43,7 @@ from fli.models import (TripType,)from fli.search import SearchDates, SearchFlights+from fli.search.dates import MAX_DATES_PER_SEARCHclass FlightSearchConfig(BaseSettings):@@ -109,6 +110,12 @@ async def health_check(_request: Request) -> JSONResponse:# Request/Response Models# =============================================================================+# Filters the API surface still accepts but the current transport cannot+# honour (see "Search transport" in README.md). Spelled out in every+# parameter description because an LLM caller reads the tool schema, not the+# README.+_IGNORED_BY_TRANSPORT = "Currently ignored by the search-page transport (logged as a warning)."+class FlightSearchParams(BaseModel):"""Parameters for searching flights on a specific date."""@@ -151,13 +158,23 @@ class FlightSearchParams(BaseModel):)infants_on_lap: int = Field(0, ge=0, description="Number of lap infants (under 2, no seat)")exclude_basic_economy: bool = Field(- False, description="Exclude basic economy fares from results"+ False,+ description=f"Exclude basic economy fares from results. {_IGNORED_BY_TRANSPORT}",+ )+ emissions: str = Field(+ "ALL",+ description=f"Filter by emissions level: ALL or LESS. {_IGNORED_BY_TRANSPORT}",)- emissions: str = Field("ALL", description="Filter by emissions level: ALL or LESS")checked_bags: int = Field(- 0, ge=0, le=2, description="Number of checked bags to include in price (0, 1, or 2)"+ 0,+ ge=0,+ le=2,+ description=f"Number of checked bags in price (0-2). {_IGNORED_BY_TRANSPORT}",+ )+ carry_on: bool = Field(+ False,+ description=f"Include carry-on bag fee in displayed price. {_IGNORED_BY_TRANSPORT}",)- carry_on: bool = Field(False, description="Include carry-on bag fee in displayed price")show_all_results: bool = Field(True, description="Return all available results instead of curated ~30")@@ -212,7 +229,12 @@ class DateSearchParams(BaseModel):description="Arrival airport IATA code(s), comma-separated for multiple (e.g., 'LHR,CDG')")start_date: str = Field(description="Start of date range in YYYY-MM-DD format")- end_date: str = Field(description="End of date range in YYYY-MM-DD format")+ end_date: str = Field(+ description=(+ "End of date range in YYYY-MM-DD format. A range may span at most "+ f"{MAX_DATES_PER_SEARCH} dates; each date costs its own page fetch."+ )+ )trip_duration: int = Field(3, ge=1, description="Trip duration in days (for round-trip searches)")@@ -440,9 +462,11 @@ def _serialize_layover(layover: Any) -> dict[str, Any]:def _flight_extras(flight: Any) -> dict[str, Any]:"""Surface optional rich fields when populated by the parser.- Emissions fields (``co2_emissions_g`` etc.) are deliberately omitted —- the ``--emissions LESS`` filter still flows through to Google, but- raw CO₂ numbers are not part of the tool's response shape.+ Emissions fields (``co2_emissions_g`` etc.) are deliberately omitted:+ raw CO₂ numbers are not part of the tool's response shape. Note the+ ``emissions`` filter itself is currently ignored by the search-page+ transport too — it has no ``tfs`` field — and the search logs a warning+ naming it. See "Search transport" in README.md."""out: dict[str, Any] = {}for src, key in (@@ -629,6 +653,28 @@ def _build_flight_filters(return filters, trip_type, origins, destinations+def _search_error_message(exc: Exception, prefix: str = "Search failed") -> str:+ """Render a search exception for an MCP response, with actionable hints.++ `SearchParseError` means a page arrived that we could not read, which is+ most often Google's regional consent interstitial. The CLI already points+ at `FLI_SOCS_COOKIE` for that; an MCP caller has no log file to consult, so+ it needs the hint in the response itself.+ """+ from fli.search.exceptions import SearchParseError++ if isinstance(exc, SearchParseError):+ return (+ f"{prefix}: {exc} This is usually a transient page variant or a regional "+ "consent interstitial — retry, or check FLI_SOCS_COOKIE if you are in the "+ "EU/EEA."+ )+ # Everything else already carries its own actionable text —+ # `SearchRejectedError` names the gated header and the issue, and the+ # client's typed errors name the host and what to check.+ return f"{prefix}: {exc}"++def _execute_flight_search(params: FlightSearchParams) -> dict[str, Any]:"""Execute a flight search and return formatted results."""try:@@ -696,7 +742,7 @@ def _execute_flight_search(params: FlightSearchParams) -> dict[str, Any]:except ValidationError as e:return {"success": False, "error": format_validation_error(e), "flights": []}except Exception as e:- return {"success": False, "error": f"Search failed: {e}", "flights": []}+ return {"success": False, "error": _search_error_message(e), "flights": []}def _execute_booking_options(@@ -791,7 +837,11 @@ def _execute_booking_options(except ValidationError as e:return {"success": False, "error": format_validation_error(e), "options": []}except Exception as e:- return {"success": False, "error": f"Booking lookup failed: {e}", "options": []}+ return {+ "success": False,+ "error": _search_error_message(e, "Booking lookup failed"),+ "options": [],+ }def _execute_date_search(params: DateSearchParams) -> dict[str, Any]:@@ -895,7 +945,7 @@ def _execute_date_search(params: DateSearchParams) -> dict[str, Any]:except ValidationError as e:return {"success": False, "error": format_validation_error(e), "dates": []}except Exception as e:- return {"success": False, "error": f"Search failed: {str(e)}", "dates": []}+ return {"success": False, "error": _search_error_message(e), "dates": []}# =============================================================================@@ -971,19 +1021,23 @@ def search_flights(] = 0,exclude_basic_economy: Annotated[bool,- Field(description="Exclude basic economy fares from results"),+ Field(description=f"Exclude basic economy fares from results. {_IGNORED_BY_TRANSPORT}"),] = False,emissions: Annotated[str,- Field(description="Filter by emissions level: ALL or LESS"),+ Field(description=f"Filter by emissions level: ALL or LESS. {_IGNORED_BY_TRANSPORT}"),] = "ALL",checked_bags: Annotated[int,- Field(description="Number of checked bags to include in price (0, 1, or 2)", ge=0, le=2),+ Field(+ description=f"Number of checked bags in price (0-2). {_IGNORED_BY_TRANSPORT}",+ ge=0,+ le=2,+ ),] = 0,carry_on: Annotated[bool,- Field(description="Include carry-on bag fee in displayed price"),+ Field(description=f"Include carry-on bag fee in displayed price. {_IGNORED_BY_TRANSPORT}"),] = False,show_all_results: Annotated[bool,@@ -1092,7 +1146,15 @@ def search_dates(),],start_date: Annotated[str, Field(description="Start of date range in YYYY-MM-DD format")],- end_date: Annotated[str, Field(description="End of date range in YYYY-MM-DD format")],+ end_date: Annotated[+ str,+ Field(+ description=(+ "End of date range in YYYY-MM-DD format. A range may span at most "+ f"{MAX_DATES_PER_SEARCH} dates; each date costs its own page fetch."+ )+ ),+ ],trip_duration: Annotated[int,Field(description="Trip duration in days for round-trips", ge=1),@@ -1271,7 +1333,7 @@ def get_booking_options(] = None,exclude_basic_economy: Annotated[bool,- Field(description="Exclude basic economy fares from results"),+ Field(description=f"Exclude basic economy fares from results. {_IGNORED_BY_TRANSPORT}"),] = False,currency: Annotated[str | None,@@ -1318,15 +1380,19 @@ def get_booking_options(] = None,emissions: Annotated[str,- Field(description="Filter by emissions level: ALL or LESS"),+ Field(description=f"Filter by emissions level: ALL or LESS. {_IGNORED_BY_TRANSPORT}"),] = "ALL",checked_bags: Annotated[int,- Field(description="Number of checked bags to include in price (0, 1, or 2)", ge=0, le=2),+ Field(+ description=f"Number of checked bags in price (0-2). {_IGNORED_BY_TRANSPORT}",+ ge=0,+ le=2,+ ),] = 0,carry_on: Annotated[bool,- Field(description="Include carry-on bag fee in displayed price"),+ Field(description=f"Include carry-on bag fee in displayed price. {_IGNORED_BY_TRANSPORT}"),] = False,) -> dict[str, Any]:"""Get bookable fares (vendor names, prices, and direct booking URLs) for a flight.diff --git a/fli/models/google_flights/base.py b/fli/models/google_flights/base.pyindex 9f828ad..fc6b8d5 100644--- a/fli/models/google_flights/base.py+++ b/fli/models/google_flights/base.py@@ -22,6 +22,17 @@ from fli.models.airline import Airlinefrom fli.models.airport import Airport+def utc_today() -> date:+ """Return today's date in UTC.++ Every date check in this package reads the clock through this one+ function, which gives tests a single seam: pinning ``utc_today`` freezes+ validation's notion of "today" so fixtures captured from Google on a+ fixed date keep working after that date has passed.+ """+ return datetime.now(timezone.utc).date()++def earliest_searchable_date() -> date:"""Return the earliest date that is still "today" somewhere on Earth.@@ -38,7 +49,7 @@ def earliest_searchable_date() -> date:The cost is that a genuinely past date may reach Google, which simplyreturns no flights — a better failure than refusing a valid search."""- return datetime.now(timezone.utc).date() - timedelta(days=1)+ return utc_today() - timedelta(days=1)class SeatType(Enum):diff --git a/fli/models/google_flights/dates.py b/fli/models/google_flights/dates.pyindex 49b7e0b..a990bc2 100644--- a/fli/models/google_flights/dates.py+++ b/fli/models/google_flights/dates.py@@ -1,6 +1,6 @@import jsonimport urllib.parse-from datetime import datetime, timedelta, timezone+from datetime import datetime, timedeltafrom enum import Enumfrom pydantic import (@@ -25,6 +25,7 @@ from fli.models.google_flights.base import (SeatType,TripType,earliest_searchable_date,+ utc_today,)MAX_PAST_FROM_DATE_DAYS = 6@@ -137,7 +138,7 @@ class DateSearchFilters(BaseModel):to_date = self.parsed_to_date.date()# The clamp target is plain "today", not the rejection floor: anchoring it# to earliest_searchable_date() would widen MAX_PAST_FROM_DATE_DAYS by a day.- current_date = datetime.now(timezone.utc).date()+ current_date = utc_today()if from_date < current_date:delta = current_date - from_datediff --git a/fli/search/__init__.py b/fli/search/__init__.pyindex 91dc068..79410f7 100644--- a/fli/search/__init__.py+++ b/fli/search/__init__.py@@ -3,7 +3,10 @@ from .exceptions import (SearchClientError,SearchConnectionError,SearchHTTPError,+ SearchParseError,+ SearchRejectedError,SearchTimeoutError,+ SearchUnsupportedError,)from .flights import SearchFlights@@ -15,4 +18,7 @@ __all__ = ["SearchTimeoutError","SearchConnectionError","SearchHTTPError",+ "SearchParseError",+ "SearchRejectedError",+ "SearchUnsupportedError",]diff --git a/fli/search/_proto.py b/fli/search/_proto.pyindex 4372a3a..7c2ce8c 100644--- a/fli/search/_proto.py+++ b/fli/search/_proto.py@@ -33,6 +33,7 @@ from __future__ import annotationsimport base64import logging+from collections.abc import Sequencefrom dataclasses import dataclasslogger = logging.getLogger(__name__)@@ -242,6 +243,134 @@ def _to_urlsafe_b64(data: bytes) -> str:return base64.urlsafe_b64encode(data).decode("ascii").rstrip("=")+# ``tfs`` is the itinerary parameter shared by booking deep links and the+# public search page. Both builders below write the same message, so the+# field layout lives here once:+#+# 1 = 28 (constant) 8 = passenger kind, repeated+# 2 = 2 (constant) 9 = cabin class+# 3 = segment, repeated 14 = 1 (constant)+# 3.2 = departure date 16 = max-uint64 pin (deep links only)+# 3.4 = selected leg, rep. 19 = 2 one-way / multi-city, 1 round-trip+# 3.5 = stop ceiling+# 3.6 = carrier include, repeated (IATA code or alliance name)+# 3.7 = carrier exclude, repeated (same values as 3.6)+# 3.13 = origin 3.14 = destination+# 3.15 = layover airport include, repeated+# 3.17 = min layover minutes 3.18 = max layover minutes+#+# Reverse-engineered from live browser captures; see+# ``.reverse-eng/notes/booking_results.md``.++_MAX_U64 = (1 << 64) - 1+++def encode_tfs_segment(+ origin: str,+ dest: str,+ date: str,+ legs: Sequence[LegSpec] = (),+ max_stops: int | None = None,+ carriers: Sequence[str] = (),+ carriers_exclude: Sequence[str] = (),+ layover_airports: Sequence[str] = (),+ min_layover: int | None = None,+ max_layover: int | None = None,+) -> bytes:+ """Encode one travel direction of a ``tfs`` itinerary.++ Args:+ origin: IATA code the direction departs from.+ dest: IATA code the direction arrives at.+ date: Departure date in ``YYYY-MM-DD`` format.+ legs: Physical flights pinned for this direction, if any. Supplying+ them narrows a search to itineraries that include them — that is+ how a round-trip search asks for return options against a chosen+ outbound.+ max_stops: Stop ceiling, zero-based (``0`` = non-stop, ``1`` = one+ stop or fewer). ``None`` leaves the search unconstrained;+ passing ``0`` for "any" would pin it to non-stop instead.+ carriers: Only itineraries on these carriers. Google takes airline+ IATA codes and alliance names (``"STAR_ALLIANCE"``) in the same+ list.+ carriers_exclude: The same values, as an exclude list.+ layover_airports: Only these airports may be used as layover stops.+ min_layover: Minimum layover wait, in minutes.+ max_layover: Maximum layover wait, in minutes.++ Returns:+ The length-delimited field 3 bytes for this segment.++ """+ body = _length_delim(2, date.encode())+ if max_stops is not None:+ body += _varint_field(5, max_stops)+ for code in carriers:+ body += _length_delim(6, code.encode())+ for code in carriers_exclude:+ body += _length_delim(7, code.encode())+ for leg in legs:+ body += _length_delim(+ 4,+ _length_delim(1, leg.origin.encode())+ + _length_delim(2, leg.dep_date.encode())+ + _length_delim(3, leg.dest.encode())+ + _length_delim(5, leg.airline.encode())+ + _length_delim(6, leg.flight_number.encode()),+ )+ for code in [origin] if isinstance(origin, str) else origin:+ body += _length_delim(13, _varint_field(1, 1) + _length_delim(2, code.encode()))+ for code in [dest] if isinstance(dest, str) else dest:+ body += _length_delim(14, _varint_field(1, 1) + _length_delim(2, code.encode()))+ for code in layover_airports:+ body += _length_delim(15, code.encode())+ if min_layover is not None:+ body += _varint_field(17, min_layover)+ if max_layover is not None:+ body += _varint_field(18, max_layover)+ return _length_delim(3, body)+++def encode_tfs_payload(+ segments: bytes,+ *,+ is_one_way: bool,+ passengers: Sequence[int] = (1,),+ seat: int = 1,+ pin_max_u64: bool = False,+) -> str:+ """Wrap encoded segments in the ``tfs`` envelope and base64 it.++ Args:+ segments: Concatenated output of :func:`encode_tfs_segment`.+ is_one_way: ``True`` for one-way, ``False`` for round-trip.+ Controls field 19. Multi-city is a third value (3) that the+ search page cannot serve — see :func:`fli.search._tfs.build_tfs`.+ passengers: Passenger kind codes, one entry per traveller+ (1 = adult, 2 = child, 3 = infant on lap, 4 = infant in own+ seat). The two infant codes are the ones to get right: a lap+ infant prices at ~10% of the adult fare and an infant in its own+ seat at ~100%, and transposing them produces a plausible wrong+ quote rather than an error. See ``_PASSENGER_FIELDS`` in+ :mod:`fli.search._tfs` for the live fare evidence.+ seat: Cabin class (1 = economy, 2 = premium, 3 = business, 4 = first).+ pin_max_u64: Emit the field 16 constant that booking deep links+ carry. The search page does not need it.++ Returns:+ URL-safe base64 string with padding stripped.++ """+ payload = _varint_field(1, 28) + _varint_field(2, 2) + segments+ for kind in passengers:+ payload += _varint_field(8, kind)+ payload += _varint_field(9, seat) + _varint_field(14, 1)+ if pin_max_u64:+ payload += _length_delim(16, _varint_field(1, _MAX_U64))+ payload += _varint_field(19, 2 if is_one_way else 1)+ return _to_urlsafe_b64(payload)++def build_tfs_token(segments: list[list[LegSpec]],*,@@ -263,8 +392,8 @@ def build_tfs_token(segments: Ordered list of travel directions. Each element is a listof :class:`LegSpec` describing every physical leg in thatdirection (one leg for nonstop, two or more for connections).- is_one_way: ``True`` for one-way (including multi-city); ``False``- for round-trip. Controls the ``f19`` constant.+ is_one_way: ``True`` for one-way; ``False`` for round-trip.+ Controls the ``f19`` constant.seat: Cabin class encoded in field 9. ``1`` = economy, ``2`` =premium economy, ``3`` = business, ``4`` = first. Defaults toeconomy so existing callers keep producing the captured tokens.@@ -283,46 +412,8 @@ def build_tfs_token(if not seg:raise ValueError(f"segment {i} has no legs")- segment_protos = b""- for seg in segments:- # Each leg becomes a repeated f4 within this segment.- legs_proto = b""- for leg in seg:- leg_proto = (- _length_delim(1, leg.origin.encode())- + _length_delim(2, leg.dep_date.encode())- + _length_delim(3, leg.dest.encode())- + _length_delim(5, leg.airline.encode())- + _length_delim(6, leg.flight_number.encode())- )- legs_proto += _length_delim(4, leg_proto)-- origin_iata = seg[0].origin- dest_iata = seg[-1].dest- seg_date = seg[0].dep_date-- seg_proto = (- _length_delim(2, seg_date.encode())- + legs_proto- + _length_delim(13, _varint_field(1, 1) + _length_delim(2, origin_iata.encode()))- + _length_delim(14, _varint_field(1, 1) + _length_delim(2, dest_iata.encode()))- )- segment_protos += _length_delim(3, seg_proto)-- # f16 constant: max uint64 (0xFFFFFFFFFFFFFFFF)- _MAX_U64 = (1 << 64) - 1-- # f19: 2 = one-way / multi-city, 1 = round-trip- f19 = 2 if is_one_way else 1-- payload = (- _varint_field(1, 28)- + _varint_field(2, 2)- + segment_protos- + _varint_field(8, 1)- + _varint_field(9, seat) # 1=economy 2=premium 3=business 4=first- + _varint_field(14, 1)- + _length_delim(16, _varint_field(1, _MAX_U64))- + _varint_field(19, f19)+ encoded = b"".join(+ encode_tfs_segment(seg[0].origin, seg[-1].dest, seg[0].dep_date, legs=seg)+ for seg in segments)- return _to_urlsafe_b64(payload)+ return encode_tfs_payload(encoded, is_one_way=is_one_way, seat=seat, pin_max_u64=True)diff --git a/fli/search/_tfs.py b/fli/search/_tfs.pynew file mode 100644index 0000000..50258c0--- /dev/null+++ b/fli/search/_tfs.py@@ -0,0 +1,353 @@+"""Search transport built on Google Flights' public ``/travel/flights`` page.++Since 2026-08 the ``FlightsFrontendService`` RPC endpoints+(``GetShoppingResults``, ``GetCalendarGraph``) require an+``x-goog-batchexecute-bgr`` header that only the page's own JavaScript can+produce. The signature is bound to the exact request bytes, so a captured+token cannot be replayed against a different body — every plain HTTP client+gets HTTP 200 with a payload-less ``wrb.fr`` row carrying error 13.++The public search page is not gated that way. It serves the same result+payload inline, in an ``AF_initDataCallback`` blob keyed ``ds:1``, whose+elements ``[2]`` and ``[3]`` hold exactly the flight rows the RPC used to+return — so :mod:`fli.search._decoders` keeps working untouched. The page is+addressed by a ``tfs`` protobuf parameter instead of the ``f.req`` JSON+struct, which is what this module builds.++Scope note: ``tfs`` carries trip type, segments, stop limit, cabin,+passengers, alliances and layover restrictions. Filters with no known+``tfs`` field (airline include/exclude, price cap, duration, departure+window) are applied to the decoded results instead — see+:func:`apply_client_side_filters`. Anything that can be+neither encoded nor filtered after the fact is reported by+:func:`unsupported_filters` so the caller can warn rather than silently+return results that ignore it.++Multi-city is out of reach here entirely: the page inlines no rows for it,+so :func:`build_tfs` refuses those searches rather than returning the first+leg's one-way board.+"""++from __future__ import annotations++import json+import logging+import re+import time+from typing import TYPE_CHECKING, Any++from fli.models.google_flights.base import TripType+from fli.search._proto import LegSpec, encode_tfs_payload, encode_tfs_segment+from fli.search.exceptions import SearchUnsupportedError++if TYPE_CHECKING:+ from fli.models import FlightResult++logger = logging.getLogger(__name__)++PAGE_URL = "https://www.google.com/travel/flights"++# Roughly one page in sixty comes back HTTP 200 with every other+# ``AF_initDataCallback`` block present but no ``ds:1`` one — a transient+# variant, not a block: the identical request succeeds seconds later. A round+# trip fetches six pages and a date sweep one per date, so at that rate an+# unretried search fails noticeably often.+#+# Retry only this exact case. HTTP errors and error-13 rejections are already+# handled (and retried, where appropriate) by the client, and re-fetching them+# here would just multiply a hard failure. Worst case is 3 fetches per page,+# so a healthy N-date sweep stays N requests.+PAGE_FETCH_ATTEMPTS = 3+PAGE_RETRY_BACKOFF = (0.5, 1.5)++# Indirection so tests can observe the backoff without sleeping and without+# patching the global ``time`` module.+_sleep = time.sleep++# ``AF_initDataCallback({key: 'ds:1', hash: '..', data:[...], sideChannel: {}});``+_DS_BLOB = re.compile(r"AF_initDataCallback\((\{.*?\})\);", re.S)+_DS_KEY = re.compile(r"key:\s*'([^']+)'")+_DS_DATA = re.compile(r"data:(.*?), sideChannel", re.S)++# Passenger kinds, in the order Google's repeated field 8 numbers them:+# 1 = adult, 2 = child, 3 = infant on lap, 4 = infant in own seat.+#+# The two infant codes are easy to transpose and the mistake is expensive+# rather than loud: on an international route a lap infant prices at ~10% of+# the adult fare and an infant in its own seat at ~100%, so a swap quotes a+# plausible but wrong fare instead of erroring. Pricing one fixed itinerary+# (BA178 JFK->LHR, economy) confirms the mapping — $295 for ``[1]``, $324 for+# ``[1, 3]`` (+10%, lap), $589 for ``[1, 4]`` (+100%, own seat, same as the+# ``[1, 2]`` child fare). The legacy RPC struct orders the same four counts+# ``[adults, children, infants_on_lap, infants_in_seat]``; see+# ``FlightSearchFilters.format`` in :mod:`fli.models.google_flights.flights`.+_PASSENGER_FIELDS = ("adults", "children", "infants_on_lap", "infants_in_seat")++# Filters with no ``tfs`` encoding and no reliable post-hoc equivalent —+# the decoded rows don't carry the data needed to apply them locally.+_UNSUPPORTED = (+ "emissions",+ "bags",+ "exclude_basic_economy",+)+++def _iata(value: Any) -> str:+ """Return the bare IATA code for an ``Airport``/``Airline`` enum or string."""+ name = getattr(value, "name", None)+ return (name or str(value)).removeprefix("_")+++def _legs_of(flight: FlightResult) -> list[LegSpec]:+ """Describe a chosen itinerary as the leg specs ``tfs`` pins it by."""+ return [+ LegSpec(+ origin=_iata(leg.departure_airport),+ dep_date=leg.departure_datetime.strftime("%Y-%m-%d"),+ dest=_iata(leg.arrival_airport),+ airline=_iata(leg.airline),+ flight_number=str(leg.flight_number),+ )+ for leg in flight.legs+ ]+++def build_tfs(filters: Any, *, travel_dates: list[str] | None = None) -> str:+ """Build the ``tfs`` URL parameter for ``filters``.++ Args:+ filters: A ``FlightSearchFilters`` or ``DateSearchFilters``. Both+ carry ``trip_type``, ``passenger_info``, ``flight_segments``,+ ``stops`` and ``seat_type``, which is all this encoder reads.+ travel_dates: Optional per-segment date overrides, used by the date+ sweep to reprice one segment set across a range without+ deep-copying the whole filter object per day.++ Returns:+ The base64url ``tfs`` value, unpadded, as Google's own URLs carry it.++ Raises:+ SearchUnsupportedError: For multi-city trips, which this transport+ cannot serve at all.++ """+ # Field 19 is the trip type. Multi-city is 3, but sending 2 (one-way)+ # makes Google ignore every segment past the first and serve the first+ # leg's one-way board, which decodes cleanly into wrong results; sending+ # 3 renders the right board in a browser but inlines no flight rows —+ # multi-city is fetched client-side through the RPC gated since 2026-08.+ if filters.trip_type == TripType.MULTI_CITY:+ raise SearchUnsupportedError(+ "Multi-city search is not available through the search-page transport: "+ "Google loads those results client-side through the gated RPC, so the "+ "page carries no rows to read. Search each leg separately. "+ "See github.com/punitarani/fli#223."+ )++ stops = filters.stops.value+ passengers = [+ code+ for kind, code in zip(_PASSENGER_FIELDS, (1, 2, 3, 4), strict=False)+ for _ in range(getattr(filters.passenger_info, kind, 0))+ ]++ # Google reads alliances out of the same carrier lists as airline codes.+ carriers = [a.value for a in (getattr(filters, "alliances", None) or [])]+ carriers_exclude = [a.value for a in (getattr(filters, "alliances_exclude", None) or [])]+ layovers = getattr(filters, "layover_restrictions", None)++ segments = b""+ for index, segment in enumerate(filters.flight_segments):+ selected = segment.selected_flight+ segments += encode_tfs_segment(+ [_iata(entry[0]) for entry in segment.departure_airport],+ [_iata(entry[0]) for entry in segment.arrival_airport],+ travel_dates[index] if travel_dates else segment.travel_date,+ legs=_legs_of(selected) if selected is not None else (),+ # MaxStops.ANY (0) must leave the field out — writing 0 for it+ # would silently pin every search to non-stop.+ max_stops=stops - 1 if stops else None,+ carriers=carriers,+ carriers_exclude=carriers_exclude,+ layover_airports=[_iata(a) for a in (getattr(layovers, "airports", None) or [])],+ min_layover=getattr(layovers, "min_duration", None),+ max_layover=getattr(layovers, "max_duration", None),+ )++ return encode_tfs_payload(+ segments,+ is_one_way=filters.trip_type == TripType.ONE_WAY,+ passengers=passengers or [1],+ seat=filters.seat_type.value,+ )+++def page_url(+ tfs: str,+ currency: str | None = None,+ language: str | None = None,+ country: str | None = None,+) -> str:+ """Build the search-page URL for a ``tfs`` value and locale."""+ params = [f"tfs={tfs}", f"hl={language or 'en'}", f"gl={country or 'US'}"]+ if currency:+ params.append(f"curr={currency}")+ return f"{PAGE_URL}?{'&'.join(params)}"+++def extract_payload(html: str) -> Any | None:+ """Pull the ``ds:1`` payload out of a rendered search page.++ Returns the same structure the RPC used to hand back, so callers can+ keep reading ``payload[2]`` / ``payload[3]`` for flight rows.+ """+ for match in _DS_BLOB.finditer(html):+ blob = match.group(1)+ key = _DS_KEY.search(blob)+ if not key or key.group(1) != "ds:1":+ continue+ data = _DS_DATA.search(blob)+ if not data:+ continue+ try:+ return json.loads(data.group(1))+ except (ValueError, json.JSONDecodeError) as exc:+ # One concise line. This sits on the per-page path, which the+ # retry below runs up to three times and a date sweep runs once+ # per date — with no logging configured, `exc_info` here would+ # put hundreds of full tracebacks on stderr through+ # `logging.lastResort`. The traceback stays at DEBUG.+ logger.warning("ds:1 blob is not valid JSON: %s", exc)+ logger.debug("ds:1 blob decode failed", exc_info=True)+ return None+ return None+++def fetch_payload(client: Any, url: str) -> Any | None:+ """Fetch a search page and return its ``ds:1`` payload, or ``None``.++ The single entry point both the flight search and the date sweep use, so+ the transient-page retry described at :data:`PAGE_FETCH_ATTEMPTS` applies+ identically to each. Only a 200 with no ``ds:1`` blob is retried; HTTP and+ network errors propagate on the first attempt exactly as before.++ Args:+ client: Anything with a ``get(url, **kwargs)`` returning a response+ with ``.text`` and ``.raise_for_status()``.+ url: The fully built search-page URL.++ Returns:+ The decoded payload, or ``None`` when every attempt came back without+ one — the caller decides whether that is fatal.++ """+ for attempt in range(PAGE_FETCH_ATTEMPTS):+ response = client.get(url, impersonate="chrome", allow_redirects=True)+ response.raise_for_status()+ payload = extract_payload(response.text)+ if payload is not None:+ if attempt:+ logger.info("Search page carried ds:1 on attempt %d", attempt + 1)+ return payload+ if attempt + 1 < PAGE_FETCH_ATTEMPTS:+ delay = PAGE_RETRY_BACKOFF[min(attempt, len(PAGE_RETRY_BACKOFF) - 1)]+ logger.debug(+ "Search page carried no ds:1 payload (attempt %d/%d); retrying in %.1fs",+ attempt + 1,+ PAGE_FETCH_ATTEMPTS,+ delay,+ )+ _sleep(delay)+ return None+++def unsupported_filters(filters: Any) -> list[str]:+ """Name the set filters this transport can neither encode nor emulate."""+ named = []+ for attr in _UNSUPPORTED:+ value = getattr(filters, attr, None)+ if value in (None, False, []):+ continue+ # Enum defaults (EmissionsFilter.ALL) are "unset" for our purposes.+ if getattr(value, "name", None) == "ALL":+ continue+ named.append(attr)+ return named+++def apply_client_side_filters(flights: list[Any], filters: Any) -> list[Any]:+ """Apply the filters ``tfs`` has no field for, to already-decoded rows.++ Google would have applied these server-side and back-filled the result+ list, so a filtered search returns fewer options here than the old RPC+ did — but every option it does return honours the filter.+ """+ airlines = {_iata(a) for a in (getattr(filters, "airlines", None) or [])}+ excluded = {_iata(a) for a in (getattr(filters, "airlines_exclude", None) or [])}+ max_duration = getattr(filters, "max_duration", None)+ price_limit = getattr(filters, "price_limit", None)+ max_price = getattr(price_limit, "max_price", None)++ # These rows describe whichever segment the caller is still choosing, not+ # necessarily the outbound one. `_expand_multi_leg` pins a segment by+ # setting its `selected_flight` and re-fetches, so the flights coming back+ # belong to the first segment that is still unpinned. Filtering a return+ # leg against the outbound window drops valid evening returns and keeps+ # invalid ones, silently and in the caller's favour-looking direction.+ active = next(+ (+ index+ for index, segment in enumerate(filters.flight_segments)+ if getattr(segment, "selected_flight", None) is None+ ),+ max(0, len(filters.flight_segments) - 1),+ )+ segments = filters.flight_segments+ window = getattr(segments[active], "time_restrictions", None) if segments else None++ out = []+ for flight in flights:+ carriers = {_iata(leg.airline) for leg in flight.legs}+ if airlines and not carriers & airlines:+ continue+ if excluded and carriers & excluded:+ continue+ if max_duration is not None and flight.duration and flight.duration > max_duration:+ continue+ if max_price is not None and flight.price and flight.price > max_price:+ continue+ if not _within_window(flight, window):+ continue+ out.append(flight)+ return out+++def _within_window(flight: Any, restrictions: Any) -> bool:+ """Check a flight's departure/arrival hours against a segment's window.++ ``FlightResult.legs`` has no minimum length and ``parse_flight_row``+ happily returns a row whose ``detail[2]`` was empty, so an unguarded+ ``legs[0]`` here raises ``IndexError`` out of the whole search on one odd+ row. A flight with no legs has no departure time to judge, so it cannot+ satisfy a time window — drop it rather than crash.+ """+ if restrictions is None:+ return True+ if not flight.legs:+ return False+ departure = flight.legs[0].departure_datetime.hour+ arrival = flight.legs[-1].arrival_datetime.hour+ checks = (+ (getattr(restrictions, "earliest_departure", None), departure, "min"),+ (getattr(restrictions, "latest_departure", None), departure, "max"),+ (getattr(restrictions, "earliest_arrival", None), arrival, "min"),+ (getattr(restrictions, "latest_arrival", None), arrival, "max"),+ )+ for bound, actual, kind in checks:+ if bound is None:+ continue+ if kind == "min" and actual < bound:+ return False+ if kind == "max" and actual > bound:+ return False+ return Truediff --git a/fli/search/_wire.py b/fli/search/_wire.pyindex ee889b3..2cbedaa 100644--- a/fli/search/_wire.py+++ b/fli/search/_wire.py@@ -58,8 +58,9 @@ def iter_wrb_chunks(body: str | bytes) -> Iterator[Any]:if not (b"0" <= raw[:1] <= b"9"):try:outer = json.loads(raw.decode("utf-8"))- except (ValueError, json.JSONDecodeError, UnicodeDecodeError):- logger.warning("Failed to decode single-chunk wrb.fr body as JSON", exc_info=True)+ except (ValueError, json.JSONDecodeError, UnicodeDecodeError) as exc:+ logger.warning("Failed to decode single-chunk wrb.fr body as JSON: %s", exc)+ logger.debug("single-chunk wrb.fr decode failed", exc_info=True)returnyield from _chunks_from_outer(outer)return@@ -88,8 +89,9 @@ def iter_wrb_chunks(body: str | bytes) -> Iterator[Any]:cursor += chunk_bytestry:outer = json.loads(payload.strip().decode("utf-8"))- except (ValueError, json.JSONDecodeError, UnicodeDecodeError):- logger.warning("Discarding malformed wrb.fr chunk", exc_info=True)+ except (ValueError, json.JSONDecodeError, UnicodeDecodeError) as exc:+ logger.warning("Discarding malformed wrb.fr chunk: %s", exc)+ logger.debug("malformed wrb.fr chunk", exc_info=True)continueyield from _chunks_from_outer(outer)@@ -105,11 +107,20 @@ def _chunks_from_outer(outer: Any) -> Iterator[Any]:continueinner = row[2]if not isinstance(inner, str) or not inner:+ # Payload-less row: Google declined the call and parked an error+ # code in slot 5. Raise instead of yielding nothing, so callers+ # don't report a hard block as "no flights on this route".+ code = row[5][0] if len(row) > 5 and isinstance(row[5], list) and row[5] else None+ if isinstance(code, int):+ from fli.search.exceptions import SearchRejectedError++ raise SearchRejectedError(code)continuetry:yield json.loads(inner)- except (ValueError, json.JSONDecodeError):- logger.warning("Failed to decode wrb.fr inner JSON payload", exc_info=True)+ except (ValueError, json.JSONDecodeError) as exc:+ logger.warning("Failed to decode wrb.fr inner JSON payload: %s", exc)+ logger.debug("wrb.fr inner JSON decode failed", exc_info=True)continuediff --git a/fli/search/client.py b/fli/search/client.pyindex 7885283..1dcbdfe 100644--- a/fli/search/client.py+++ b/fli/search/client.py@@ -72,6 +72,16 @@ if _env_timeout is not None:else:REQUEST_TIMEOUT = DEFAULT_TIMEOUT+# EU/EEA IPs are redirected to Google's consent interstitial, which serves a+# page with no ds:1 payload — every search then fails to parse. A pre-accepted+# SOCS cookie skips the interstitial (the legacy CONSENT cookie no longer+# works, and a truncated SOCS value is ignored). Override with FLI_SOCS_COOKIE+# if Google rotates the value; set it empty to send no cookie at all.+DEFAULT_SOCS_COOKIE = (+ "CAISNQgQEitib3FfaWRlbnRpdHlmcm9udGVuZHVpc2VydmVyXzIwMjQwMzE3LjA5X3AwGgJlbiADGgYIgLC_rwY"+)+SOCS_COOKIE = os.environ.get("FLI_SOCS_COOKIE", DEFAULT_SOCS_COOKIE)+class Client:"""HTTP client with built-in rate limiting, retry and user agent impersonation functionality.@@ -106,6 +116,8 @@ class Client:session = _requests.Session()session.headers.update(self.DEFAULT_HEADERS)+ if SOCS_COOKIE:+ session.cookies.set("SOCS", SOCS_COOKIE, domain=".google.com")self._sessions.session = sessionreturn sessiondiff --git a/fli/search/dates.py b/fli/search/dates.pyindex b439619..4f3a123 100644--- a/fli/search/dates.py+++ b/fli/search/dates.py@@ -6,21 +6,116 @@ It is intended to be used for finding the cheapest dates to fly, not the cheapes"""import logging+import threadingfrom copy import deepcopyfrom datetime import datetime, timedelta+from typing import Any, NamedTuplefrom pydantic import BaseModelfrom fli.core import extract_currency_from_price_token-from fli.models import DateSearchFilters-from fli.models.google_flights.base import TripType+from fli.models import DateSearchFilters, FlightResult+from fli.models.google_flights.base import TripType, earliest_searchable_datefrom fli.search._concurrency import parallel_map-from fli.search._urls import with_locale_params-from fli.search._wire import parse_first_wrb_payload+from fli.search._decoders import parse_flight_row+from fli.search._tfs import (+ apply_client_side_filters,+ build_tfs,+ fetch_payload,+ page_url,+ unsupported_filters,+)from fli.search.client import get_client+from fli.search.exceptions import SearchClientError, SearchParseErrorlogger = logging.getLogger(__name__)+# Same wording the flight path uses for the same condition, so a caller who+# sees it on either path gets the same hint about what to check.+_NO_PAYLOAD = (+ "the search page carried no ds:1 payload — Google may have changed the "+ "page shape, or served a consent/blocked page instead"+)++MAX_DATES_PER_SEARCH = 93+"""Most dates a single :meth:`SearchDates.search` call will price.++The public search page carries no calendar grid, so every date in the range+costs its own full page fetch (~2 MB). Ninety-three days is a whole quarter —+comfortably wider than the CLI's 60-day and the MCP prompt's 61-day defaults —+and caps one search at roughly 190 MB of transfer rather than letting a+"2026-01-01 to 2026-12-31" request quietly issue 365 requests.+"""++SWEEP_FAILURE_THRESHOLD = 5+"""Payload-less pages, before any success, that abandon a sweep.++Retries multiply. The client retries a request three times, and+:func:`~fli.search._tfs.fetch_payload` fetches a page up to three times, so one+date can cost nine HTTP requests before it gives up — and a client that is+being blocked (an EU/EEA IP with the consent cookie disabled, say) fails that+way on *every* date. Paying it 93 times to learn one fact is the wrong trade.++Only the payload-less page counts. That failure is deterministic: a consent or+block page is served to every request alike, so the dates not yet tried will+fail the same way. A connection error or timeout says nothing about them, so+counting those would abandon a healthy sweep over a transient wobble — they+keep the ordinary behaviour of costing their own date and nothing more.++The breaker also only looks at the start of a sweep: it arms while no date has+produced a usable page, and disarms permanently the moment one does. A working+sweep therefore keeps the full retry budget for every transient miss in it.+"""+++class _SweepHealth:+ """Tracks whether a sweep is failing the one way that is worth quitting over.++ Shared by the worker threads pricing each date, so every read and write is+ under one lock. ``should_stop`` answers "is this sweep failing+ deterministically?", which is only ever true before the first success.+ """++ __slots__ = ("_lock", "_blocked", "_any_success", "_threshold", "_skipped")++ def __init__(self, threshold: int):+ """Arm a breaker that trips after ``threshold`` payload-less pages."""+ self._lock = threading.Lock()+ self._blocked = 0+ self._any_success = False+ self._threshold = threshold+ self._skipped = 0++ def record_success(self) -> None:+ """Note a date whose page arrived; disarms the breaker for good."""+ with self._lock:+ self._any_success = True++ def record_blocked(self) -> None:+ """Note a date whose page arrived without a ``ds:1`` payload.++ Only this failure mode counts towards the threshold — see the module+ constant's docstring for why a network error deliberately does not.+ """+ with self._lock:+ self._blocked += 1++ def record_skip(self) -> None:+ """Note a date abandoned because the breaker had already tripped."""+ with self._lock:+ self._skipped += 1++ @property+ def skipped(self) -> int:+ """How many dates were abandoned without being requested."""+ with self._lock:+ return self._skipped++ def should_stop(self) -> bool:+ """Report whether the sweep has only ever been blocked, and enough times."""+ with self._lock:+ return not self._any_success and self._blocked >= self._threshold+class DatePrice(BaseModel):"""Flight price for a specific date."""@@ -30,6 +125,52 @@ class DatePrice(BaseModel):currency: str | None = None+class _DateOutcome(NamedTuple):+ """What pricing one date produced.++ Attributes:+ price: The cheapest itinerary for the date, or ``None`` when the date+ was skipped, failed, or genuinely had no flights.+ failure: Human-readable reason the date could not be priced, or+ ``None`` when the fetch succeeded (even if it found nothing).+ error: The exception behind ``failure``, kept for chaining.+ attempted: ``False`` for dates skipped before any request (past+ dates), so they don't count towards the "everything failed" check.++ """ # noqa: D413++ price: DatePrice | None = None+ failure: str | None = None+ error: BaseException | None = None+ attempted: bool = True+++def _flights_in(payload: Any) -> list[FlightResult]:+ """Decode every flight row in a ``ds:1`` payload.++ Total by construction: a payload whose ``[2]`` / ``[3]`` slots are absent,+ empty, or not the nested list we expect yields no flights instead of an+ ``IndexError`` that would abort the whole sweep. Individual unparseable+ rows are skipped the same way the flight search skips them.+ """+ flights: list[FlightResult] = []+ if not isinstance(payload, list):+ return flights+ for index in (2, 3):+ block = payload[index] if index < len(payload) else None+ if not isinstance(block, list) or not block:+ continue+ rows = block[0]+ if not isinstance(rows, list):+ continue+ for row in rows:+ try:+ flights.append(parse_flight_row(row))+ except (AttributeError, IndexError, KeyError, TypeError, ValueError):+ continue+ return flights++class SearchDates:"""Date-based flight search implementation.@@ -37,10 +178,12 @@ class SearchDates:useful for finding the cheapest dates to fly."""- BASE_URL = "https://www.google.com/_/FlightsFrontendUi/data/travel.frontend.flights.FlightsFrontendService/GetCalendarGraph"- DEFAULT_HEADERS = {- "content-type": "application/x-www-form-urlencoded;charset=UTF-8",- }+ # Dates are swept one page fetch each (see ``_price_one_date``); the+ # GetCalendarGraph RPC this class used to POST to is gated and no longer+ # reachable, so its URL and headers are gone rather than left as dead+ # constants that imply the class still speaks that protocol.++ # Range size at which the sweep splits into independent chunk filters.MAX_DAYS_PER_SEARCH = 61def __init__(self):@@ -66,42 +209,170 @@ class SearchDates:List of DatePrice objects containing date and price pairs, or None if no resultsRaises:- Exception: If the search fails or returns invalid data+ ValueError: The range covers more than :data:`MAX_DATES_PER_SEARCH`+ dates, which would cost one page fetch each.+ SearchClientError: Every date in the range failed to load.Notes:- - For date ranges larger than 61 days, splits into multiple searches.- - We can't search more than 305 days in the future.+ Every date in the range costs its own search-page fetch — the page+ serves no calendar grid — so the range is capped at+ :data:`MAX_DATES_PER_SEARCH` dates. Internally it is still split+ into ``MAX_DAYS_PER_SEARCH``-day chunk filters, but all dates are+ priced by a single flat parallel map."""+ dropped = unsupported_filters(filters)+ if dropped:+ logger.warning(+ "Filters not supported by the search-page transport, ignored: %s",+ ", ".join(dropped),+ )+from_date = datetime.strptime(filters.from_date, "%Y-%m-%d")to_date = datetime.strptime(filters.to_date, "%Y-%m-%d")- date_range = (to_date - from_date).days + 1- if date_range <= self.MAX_DAYS_PER_SEARCH:- return self._search_chunk(- filters, currency=currency, language=language, country=country+ # Build every chunk descriptor up front so the per-date requests share+ # no mutable state. This both enables parallel execution and fixes a+ # latent bug in the previous sequential version: each chunk rewrote+ # ``filters.flight_segments[*].travel_date`` in place, so the+ # second-and-later chunks had segment dates that no longer matched+ # ``current_from``.+ tasks = [+ (chunk, day)+ for chunk in self._build_chunk_filters(filters, from_date, to_date)+ for day in self._days_in(chunk)+ ]++ if len(tasks) > MAX_DATES_PER_SEARCH:+ raise ValueError(+ f"This date search covers {len(tasks)} dates, above the "+ f"{MAX_DATES_PER_SEARCH}-date limit. Google's search page serves no "+ "calendar grid, so every date costs its own full page fetch. "+ "Narrow the range (or run several smaller searches).")- # Build every chunk descriptor up front so the per-chunk requests- # share no mutable state. This both enables parallel execution and- # fixes a latent bug in the previous sequential version: each chunk- # rewrote ``filters.flight_segments[*].travel_date`` in place, so- # the second-and-later chunks had segment dates that no longer- # matched ``current_from``.- chunk_filters = self._build_chunk_filters(filters, from_date, to_date)-- chunk_results = parallel_map(- lambda cf: self._search_chunk(- cf, currency=currency, language=language, country=country+ # One flat map over every date. Nesting a second ``parallel_map``+ # inside each chunk's worker deadlocks: both levels share one bounded+ # pool, so the outer tasks can occupy every worker while blocking on+ # inner tasks that can never be scheduled.+ #+ # ``health`` is the sweep's circuit breaker: a client that is being+ # blocked fails identically on every date, and each failed date costs+ # up to nine HTTP requests once the client's retries and the page+ # retry multiply. Queued dates check it before spending anything.+ health = _SweepHealth(SWEEP_FAILURE_THRESHOLD)+ outcomes = parallel_map(+ lambda task: self._price_one_date(+ task[0],+ task[1],+ currency=currency,+ language=language,+ country=country,+ health=health,),- chunk_filters,+ tasks,)+ return self._collect(outcomes, len(tasks), skipped=health.skipped)++ def _days_in(self, filters: DateSearchFilters) -> list[datetime]:+ """List every date in one chunk's ``from_date``..``to_date`` range."""+ from_date = filters.parsed_from_date+ to_date = filters.parsed_to_date+ return [+ from_date + timedelta(days=offset) for offset in range((to_date - from_date).days + 1)+ ]- all_results: list[DatePrice] = []- for r in chunk_results:- if r:- all_results.extend(r)- return all_results if all_results else None+ @staticmethod+ def _collect(+ outcomes: list[_DateOutcome],+ total: int,+ *,+ skipped: int = 0,+ ) -> list[DatePrice] | None:+ """Assemble priced dates, raising when nothing could be fetched at all.++ A date with no flights is a legitimate answer; a date whose page never+ arrived is not. When *every* attempted date failed, returning an empty+ list would report a dead transport as "this route has no flights" —+ exactly the silent failure this client exists to avoid.++ The error type mirrors the flight path: a range where every page came+ back without a ``ds:1`` blob raises :class:`SearchParseError`, the same+ class (and hint) a single unreadable page raises there. Anything else+ raises the more general :class:`SearchClientError`.++ A sweep that tripped the circuit breaker must never end quietly either.+ With prices to show, the answer is real but incomplete, so it comes with+ one warning naming the count. With none at all the sweep is simply+ blocked — and the tripped breaker is the evidence for that, not the+ exact mix of what each attempted date happened to do.++ Args:+ outcomes: One entry per date in the range, in date order.+ total: Dates the sweep set out to price, so the error can say how+ many were abandoned when the circuit breaker stopped it.+ skipped: Dates the breaker abandoned without requesting them.+ Non-zero exactly when the breaker tripped.++ """+ results = [o.price for o in outcomes if o.price is not None]+ attempted = [o for o in outcomes if o.attempted]+ failed = [o for o in attempted if o.failure]+ # The breaker only ever trips on payload-less pages, so a non-zero skip+ # count *is* the blocked-page diagnosis, whatever else failed alongside.+ tripped = skipped > 0+ everything_failed = bool(attempted) and len(failed) == len(attempted)++ if not results and (everything_failed or tripped):+ reasons: list[str] = []+ for outcome in failed:+ if outcome.failure not in reasons and len(reasons) < 3:+ reasons.append(outcome.failure)+ cause = next((o.error for o in failed if o.error is not None), None)+ blocked = tripped or (bool(failed) and all(o.failure == _NO_PAYLOAD for o in failed))+ error_type = SearchParseError if blocked else SearchClientError++ if everything_failed:+ message = (+ f"Priced 0 of {total} dates — every date in the range failed. "+ f"Reasons: {'; '.join(reasons)}"+ )+ else:+ # Some attempted date loaded and simply had no flights, which is+ # not a failure on its own — but with nothing priced anywhere and+ # the breaker tripped, the sweep still has no usable answer.+ message = (+ f"Priced 0 of {total} dates — no date in the range could be priced. "+ f"Reasons: {'; '.join(reasons) or 'no flights on the dates that loaded'}"+ )+ if tripped:+ message += (+ f". Gave up after {len(attempted)} of {total} dates ({skipped} skipped): "+ "a sweep that has not loaded a single page is failing for the same "+ "reason on every date, and each one costs several requests"+ )+ if blocked:+ message += (+ ". If you are on an EU/EEA IP, Google's consent interstitial serves no "+ "results — the client sends a pre-accepted SOCS cookie by default, so "+ "check FLI_SOCS_COOKIE has not been set to an empty value"+ )+ raise error_type(message) from cause++ if tripped:+ # Exactly one line, whatever the sweep's size: the caller is about+ # to act on a partial answer and has no other way to know it.+ logger.warning(+ "Date sweep returned %d of %d dates: %d were skipped after %d pages came "+ "back without a ds:1 payload and none had loaded yet. The prices below are "+ "real but incomplete — retry, or check FLI_SOCS_COOKIE if you are in the "+ "EU/EEA.",+ len(results),+ total,+ skipped,+ SWEEP_FAILURE_THRESHOLD,+ )+ return results or Nonedef _build_chunk_filters(self,@@ -114,6 +385,11 @@ class SearchDates:The flight segments are deep-copied per chunk and their``travel_date`` advanced by the chunk offset so each chunkrepresents a distinct, self-contained search.++ Copies are made with ``model_copy`` rather than by re-listing fields+ in a fresh ``DateSearchFilters``: the hand-written list silently+ dropped ``airlines_exclude``, ``alliances`` and ``alliances_exclude``,+ so any search wide enough to be chunked ignored those filters."""chunks: list[DateSearchFilters] = []current_from = from_date@@ -128,83 +404,126 @@ class SearchDates:datetime.strptime(segment.travel_date, "%Y-%m-%d") + timedelta(days=shift)).strftime("%Y-%m-%d")chunks.append(- DateSearchFilters(- trip_type=filters.trip_type,- passenger_info=filters.passenger_info,- flight_segments=segments,- stops=filters.stops,- seat_type=filters.seat_type,- price_limit=filters.price_limit,- airlines=filters.airlines,- max_duration=filters.max_duration,- layover_restrictions=filters.layover_restrictions,- emissions=filters.emissions,- bags=filters.bags,- from_date=current_from.strftime("%Y-%m-%d"),- to_date=current_to.strftime("%Y-%m-%d"),- duration=filters.duration,+ filters.model_copy(+ update={+ "flight_segments": segments,+ "from_date": current_from.strftime("%Y-%m-%d"),+ "to_date": current_to.strftime("%Y-%m-%d"),+ }))current_from = current_to + timedelta(days=1)chunk_index += 1return chunks- def _search_chunk(+ def _price_one_date(self,filters: DateSearchFilters,- currency: str | None = None,- language: str | None = None,- country: str | None = None,- ) -> list[DatePrice] | None:- """Search for flight prices for a single date range chunk.-- Args:- filters: Search parameters including date range, airports, and preferences- currency: Optional ISO 4217 currency code passed via the ``curr`` URL param.- language: Optional BCP-47 language code passed via the ``hl`` URL param.- country: Optional ISO 3166-1 alpha-2 country code passed via the ``gl`` URL param.-- Returns:- List of DatePrice objects containing date and price pairs, or None if no results-- Raises:- Exception: If the search fails or returns invalid data-+ day: datetime,+ *,+ currency: str | None,+ language: str | None,+ country: str | None,+ health: "_SweepHealth | None" = None,+ ) -> _DateOutcome:+ """Price one departure date through its own search-page fetch.++ Google's ``GetCalendarGraph`` RPC used to hand back a whole date grid+ in one call, but it now requires a browser-signed+ ``x-goog-batchexecute-bgr`` header (see :mod:`fli.search._tfs`). The+ public search page has no such grid, so each date costs its own page+ fetch. Those run concurrently under the shared rate limiter.++ Returns an outcome rather than a bare ``DatePrice | None`` so the+ caller can tell "this date had no flights" apart from "this date never+ loaded" — see :meth:`_collect`.++ ``health`` is the sweep's circuit breaker. It is consulted before any+ request, so a date still queued when the sweep is already known to be+ failing deterministically costs nothing at all."""- encoded_filters = filters.encode()- url = with_locale_params(self.BASE_URL, currency, language, country)-- response = self.client.post(- url=url,- data=f"f.req={encoded_filters}",- impersonate="chrome",- allow_redirects=True,- )- response.raise_for_status()-- data = parse_first_wrb_payload(response.text)- if data is None:- return None-+ dates = [day]+ if filters.trip_type == TripType.ROUND_TRIP:+ # ``duration`` is optional (its validator doesn't run on the+ # default), so fall back to the gap between the two segments —+ # which the filter model already keeps consistent with it.+ trip_days = filters.duration+ if trip_days is None:+ segments = filters.flight_segments+ trip_days = (segments[1].parsed_travel_date - segments[0].parsed_travel_date).days+ dates.append(day + timedelta(days=trip_days))+ travel_dates = [d.strftime("%Y-%m-%d") for d in dates]++ # A date sweep can straddle today, and past dates are simply not+ # bookable — skip them rather than letting the segment validator+ # abort the whole chunk. The floor is the same one the filter models+ # validate against, so a date the models accept is never silently+ # dropped here.+ if day.date() < earliest_searchable_date():+ return _DateOutcome(attempted=False)++ # Nothing in this sweep has loaded and enough dates have failed, so+ # this one will fail too. Skip it rather than spend its retry budget;+ # ``attempted=False`` keeps it out of the "everything failed" tally,+ # which the already-failed dates satisfy on their own.+ if health is not None and health.should_stop():+ health.record_skip()+ return _DateOutcome(attempted=False)++ url = page_url(build_tfs(filters, travel_dates=travel_dates), currency, language, country)try:- items = data[-1]- except (IndexError, TypeError):- logger.warning("Date search response shape unexpected: no terminal array")- return None-- if not isinstance(items, list):- return None-- dates_data = [- DatePrice(- date=self.__parse_date(item, filters.trip_type),- price=self.__parse_price(item),- currency=self.__parse_currency(item),+ payload = fetch_payload(self.client, url)+ if payload is None:+ # Logged here rather than raised: one bad date is a warning,+ # and ``_collect`` decides whether *every* date failing is fatal.+ logger.warning(+ "Pricing %s failed: the search page carried no ds:1 payload",+ travel_dates[0],+ )+ if health is not None:+ health.record_blocked()+ return _DateOutcome(failure=_NO_PAYLOAD)++ if health is not None:+ # The page arrived and decoded; from here on the sweep is+ # healthy and later misses get their full retry budget.+ health.record_success()++ # The filters Google has no ``tfs`` field for (airlines, price cap,+ # duration, departure window) are applied to the decoded rows,+ # exactly as the flight search applies them — otherwise the+ # cheapest price for a date is taken over itineraries the caller+ # asked to exclude.+ #+ # Decoding and filtering sit inside the ``try`` on purpose: they+ # walk attacker-shaped data from the wire, and letting one odd row+ # raise out of here would sink the whole sweep, which is the class+ # of bug this method exists to avoid.+ flights = apply_client_side_filters(_flights_in(payload), filters)+ prices = [flight.price for flight in flights if flight.price]+ except Exception as exc: # noqa: BLE001 — one bad date must not sink the sweep+ # One concise line per bad date. A 93-date sweep against a blocked+ # client would otherwise print 93 full tracebacks through+ # ``logging.lastResort``, which is exactly what fli.cli.errors+ # exists to prevent. The traceback stays available at DEBUG.+ logger.warning("Pricing %s failed: %s: %s", travel_dates[0], type(exc).__name__, exc)+ logger.debug("Pricing %s failed", travel_dates[0], exc_info=True)+ # Deliberately not fed to the breaker: an exception here (a+ # timeout, a reset connection) tells us nothing about the dates+ # that have not been tried, unlike a page served without its+ # payload. See SWEEP_FAILURE_THRESHOLD.+ return _DateOutcome(failure=f"{type(exc).__name__}: {exc}", error=exc)++ if not prices:+ return _DateOutcome()++ return _DateOutcome(+ price=DatePrice(+ date=tuple(dates),+ price=min(prices),+ currency=currency,)- for item in items- if self.__parse_price(item)- ]- return dates_data+ )@staticmethoddef __parse_date(diff --git a/fli/search/exceptions.py b/fli/search/exceptions.pyindex ced740a..8e559a6 100644--- a/fli/search/exceptions.py+++ b/fli/search/exceptions.py@@ -28,3 +28,48 @@ class SearchHTTPError(SearchClientError):"""Store the HTTP status alongside the message for richer logging."""super().__init__(message)self.status_code = status_code+++class SearchRejectedError(SearchClientError):+ """Google answered HTTP 200 but declined to serve results.++ The response carries a ``wrb.fr`` row with no payload and an error+ code (13 = INTERNAL). Since 2026-08 ``GetShoppingResults`` requires an+ ``x-goog-batchexecute-bgr`` header signed by the page's own JavaScript+ over the exact request bytes, so a plain HTTP client always lands here.+ Without this error the caller saw an empty list and reported "no+ flights found", which is indistinguishable from a route with no service.+ """++ def __init__(self, code: int | None = None):+ """Record the numeric error code alongside the user-facing message."""+ self.code = code+ suffix = f" (error {code})" if code is not None else ""+ super().__init__(+ f"Google Flights declined the request{suffix} and returned no data. "+ "Its API now requires a browser-signed x-goog-batchexecute-bgr header, "+ "which this client cannot produce. See github.com/punitarani/fli#223."+ )+++class SearchUnsupportedError(SearchClientError):+ """The requested search cannot be served by the current transport.++ Distinct from an empty result: the query is well formed and Google+ would answer it in a browser, but the public search page carries no+ inline payload for it, so this client has nothing to read.+ """+++class SearchParseError(SearchClientError):+ """A successful HTTP response could not be parsed into flights.++ Distinct from network / HTTP errors: this says "Google responded but+ the shape changed", not "Google didn't respond". In practice it is+ either a consent/blocked page (no ``ds:1`` blob at all) or a change in+ the flight rows themselves.++ It belongs to the :class:`SearchClientError` family so that callers+ already catching search failures — the CLI's error reporter among them+ — classify it as one instead of an unexpected crash.+ """diff --git a/fli/search/flights.py b/fli/search/flights.pyindex b23f953..dbeed1b 100644--- a/fli/search/flights.py+++ b/fli/search/flights.py@@ -11,7 +11,9 @@ from __future__ import annotationsimport jsonimport loggingimport urllib.parse+from collections.abc import Callablefrom copy import deepcopy+from typing import Anyfrom fli.models import (BookingOption,@@ -19,28 +21,52 @@ from fli.models import (FlightSearchFilters,SeatType,)-from fli.models.google_flights.base import TripType+from fli.models.google_flights.base import SortBy, TripTypefrom fli.search._concurrency import parallel_mapfrom fli.search._decoders import (_try_parse_booking_row, # noqa: F401 — back-compat re-export for testsparse_booking_chunk,parse_flight_row,)+from fli.search._tfs import (+ apply_client_side_filters,+ build_tfs,+ fetch_payload,+ page_url,+ unsupported_filters,+)from fli.search._urls import with_locale_paramsfrom fli.search._urls import with_locale_params as _with_locale_params # noqa: F401-from fli.search._wire import iter_wrb_chunks, parse_first_wrb_payload+from fli.search._wire import iter_wrb_chunksfrom fli.search.client import get_client+from fli.search.exceptions import SearchParseErrorlogger = logging.getLogger(__name__)+# Re-exported from its original home so ``from fli.search.flights import+# SearchParseError`` keeps working; the class now lives with the rest of the+# typed error family in ``fli.search.exceptions`` so it inherits+# ``SearchClientError`` and is classified as a search failure, not a crash.+__all__ = ["SearchFlights", "SearchParseError"]+-class SearchParseError(Exception):- """Raised when a successful HTTP response cannot be parsed into flights.+def _sort_key(sort_by: SortBy) -> Callable[[FlightResult], Any]:+ """Return the result-ordering key for ``sort_by``.- Distinct from network / HTTP errors raised by the underlying client —- use this to tell "Google responded but the shape changed" apart from- "Google didn't respond at all".+ The search page serves Google's own default order, so the sort the+ caller asked for is applied here instead of in the request.+ ``TOP_FLIGHTS`` / ``BEST`` are Google's own blended rankings, which we+ can't reproduce — those keep the page's order."""+ if sort_by == SortBy.CHEAPEST:+ return lambda f: (f.price is None, f.price)+ if sort_by == SortBy.DURATION:+ return lambda f: (f.duration is None, f.duration)+ if sort_by == SortBy.DEPARTURE_TIME:+ return lambda f: f.legs[0].departure_datetime+ if sort_by == SortBy.ARRIVAL_TIME:+ return lambda f: f.legs[-1].arrival_datetime+ return lambda f: 0class SearchFlights:@@ -161,20 +187,20 @@ class SearchFlights:because the user-visible session id should describe the originalshopping query, not whichever expansion completed last."""- encoded = filters.encode()- url = with_locale_params(self.BASE_URL, currency, language, country)-- response = self.client.post(- url=url,- data=f"f.req={encoded}",- impersonate="chrome",- allow_redirects=True,- )- response.raise_for_status()+ dropped = unsupported_filters(filters)+ if dropped:+ logger.warning(+ "Filters not supported by the search-page transport, ignored: %s",+ ", ".join(dropped),+ )- inner = parse_first_wrb_payload(response.text)+ url = page_url(build_tfs(filters), currency, language, country)+ inner = fetch_payload(self.client, url)if inner is None:- return None+ raise SearchParseError(+ "Search page carried no ds:1 payload — Google may have changed "+ "the page shape, or served a consent/blocked page instead."+ )if capture_session:self._capture_session_id(inner)@@ -217,6 +243,8 @@ class SearchFlights:f"Google response shape may have changed (sample reasons: {sample})")+ flights = apply_client_side_filters(flights, filters)+ flights.sort(key=_sort_key(filters.sort_by))return flights or Nonedef get_booking_options(@@ -427,13 +455,14 @@ class SearchFlights:"""try:session_id = inner[0][4]- except (IndexError, TypeError):+ except (IndexError, TypeError) as exc:logger.warning(- "Failed to capture shopping session id from search response; "+ "Failed to capture shopping session id from search response (%s); ""subsequent get_booking_options() calls without an explicit ""session_id will fail.",- exc_info=True,+ exc,)+ logger.debug("session id capture failed", exc_info=True)returnif isinstance(session_id, str) and session_id:self._last_session_id = session_iddiff --git a/tests/cli/test_dates.py b/tests/cli/test_dates.pyindex d127d8c..79a2c5e 100644--- a/tests/cli/test_dates.py+++ b/tests/cli/test_dates.py@@ -378,3 +378,36 @@ def test_dates_json_empty_results(runner, mock_search_dates, mock_console):assert payload["success"] is Trueassert payload["count"] == 0assert payload["dates"] == []+++def test_dates_over_the_cap_reports_cleanly(runner, mock_console):+ """A range wider than the per-search date cap fails with a readable message.++ Deliberately not mocking ``SearchDates``: the cap is enforced before any+ request, and the point is that the CLI surfaces it rather than dumping a+ traceback.+ """+ from_date = (datetime.now() + timedelta(days=1)).strftime("%Y-%m-%d")+ to_date = (datetime.now() + timedelta(days=200)).strftime("%Y-%m-%d")++ result = runner.invoke(app, ["dates", "JFK", "LAX", "--from", from_date, "--to", to_date])++ assert result.exit_code == 1+ assert "93-date limit" in result.output+ assert "Traceback" not in result.output+++def test_dates_over_the_cap_json(runner, mock_console):+ """The same cap error is a structured JSON error, not a crash."""+ from_date = (datetime.now() + timedelta(days=1)).strftime("%Y-%m-%d")+ to_date = (datetime.now() + timedelta(days=200)).strftime("%Y-%m-%d")++ result = runner.invoke(+ app,+ ["dates", "JFK", "LAX", "--from", from_date, "--to", to_date, "--format", "json"],+ )++ assert result.exit_code == 1+ payload = json.loads(result.stdout)+ assert payload["success"] is False+ assert "93-date limit" in payload["error"]["message"]diff --git a/tests/cli/test_errors.py b/tests/cli/test_errors.pyindex 645f860..6c970fa 100644--- a/tests/cli/test_errors.py+++ b/tests/cli/test_errors.py@@ -29,6 +29,17 @@ def _isolated_tmp_log_dir(monkeypatch, tmp_path):monkeypatch.setattr("fli.cli.errors._LOG_DIR", tmp_path / "fli-logs")+# The CLI invocations below pass fixed travel dates; pin the models' clock so+# they stay in the future no matter when the suite runs.+PINNED_TODAY = "2026-01-01"++[email protected](autouse=True)+def _pinned_clock(pin_today):+ """Freeze "today" well before every date literal in this module."""+ pin_today(PINNED_TODAY)++def test_write_log_creates_file_with_traceback(tmp_path):"""`_write_log` should write a file containing the traceback details."""try:@@ -77,15 +88,33 @@ def test_report_cli_error_returns_typer_exit_and_writes_log(tmp_path, capsys):assert len(log_files) == 1-def test_multi_command_handles_timeout_cleanly(runner, monkeypatch, tmp_path):- """A curl timeout inside `multi` should produce a clean message + log file."""+def test_search_command_handles_timeout_cleanly(runner, monkeypatch, tmp_path):+ """A curl timeout inside a search should produce a clean message + log file."""from curl_cffi.requests import exceptions as curl_exc- def fake_post(self, url, **kwargs):+ def fake_request(self, url, **kwargs):raise curl_exc.Timeout("curl: (28) timed out", 28, None)- monkeypatch.setattr("curl_cffi.requests.Session.post", fake_post)+ # Search reads the public page over GET; booking calls still POST. Stub+ # both so the test covers the failure wherever the request is made.+ monkeypatch.setattr("curl_cffi.requests.Session.get", fake_request)+ monkeypatch.setattr("curl_cffi.requests.Session.post", fake_request)+ result = runner.invoke(app, ["flights", "SEA", "NRT", "2026-12-26"])++ assert result.exit_code == 1+ # Friendly message — no raw curl traceback in the output.+ assert "Error" in result.output+ assert "Timed out talking to Google Flights" in result.output+ assert "Full traceback written to" in result.output+ assert "Traceback (most recent call last)" not in result.output++ log_files = list((tmp_path / "fli-logs").glob("fli-error-*.log"))+ assert len(log_files) >= 1+++def test_multi_command_reports_unsupported(runner, tmp_path):+ """Multi-city has no search-page transport — say so instead of pricing one leg."""result = runner.invoke(app,[@@ -100,15 +129,9 @@ def test_multi_command_handles_timeout_cleanly(runner, monkeypatch, tmp_path):)assert result.exit_code == 1- # Friendly message — no raw curl traceback in the output.- assert "Error" in result.output- assert "Timed out talking to Google Flights" in result.output- assert "Full traceback written to" in result.output+ assert "Multi-city search is not available" in result.outputassert "Traceback (most recent call last)" not in result.output- log_files = list((tmp_path / "fli-logs").glob("fli-error-*.log"))- assert len(log_files) >= 1-@pytest.mark.parametrize("exc, expected_msg",@@ -198,10 +221,11 @@ def test_flights_command_json_error_includes_log_path(runner, monkeypatch, tmp_pfrom curl_cffi.requests import exceptions as curl_exc- def fake_post(self, url, **kwargs):+ def fake_request(self, url, **kwargs):raise curl_exc.ConnectionError("dns lookup failed", 6, None)- monkeypatch.setattr("curl_cffi.requests.Session.post", fake_post)+ monkeypatch.setattr("curl_cffi.requests.Session.get", fake_request)+ monkeypatch.setattr("curl_cffi.requests.Session.post", fake_request)result = runner.invoke(app,@@ -214,3 +238,50 @@ def test_flights_command_json_error_includes_log_path(runner, monkeypatch, tmp_passert payload["error"]["type"] == "connection_error"assert "log_path" in payload["error"]assert Path(payload["error"]["log_path"]).exists()+++class TestTransportErrorClassification:+ """`SearchParseError` used to surface as "Unexpected error" in the CLI.++ It is raised on the normal flight path whenever Google serves a+ consent/blocked page, so it needs to read as a search failure with a+ useful hint, not as a crash.+ """++ def test_parse_error_is_a_search_client_error(self):+ from fli.search import SearchParseError as exported+ from fli.search.exceptions import SearchClientError as base+ from fli.search.flights import SearchParseError as from_flights++ assert exported is from_flights+ assert issubclass(exported, base)++ def test_parse_error_message_is_actionable(self):+ from fli.cli.errors import _friendly_message+ from fli.search import SearchParseError++ message = _friendly_message(SearchParseError("Search page carried no ds:1 payload"))+ assert "Unexpected error" not in message+ assert "ds:1" in message+ assert "FLI_SOCS_COOKIE" in message++ def test_rejected_error_message_is_specific(self):+ from fli.cli.errors import _friendly_message+ from fli.search import SearchRejectedError++ message = _friendly_message(SearchRejectedError(13))+ assert "Unexpected error" not in message+ assert "declined the request" in message++ @pytest.mark.parametrize(+ ("exc_factory", "expected_type"),+ [+ (lambda: __import__("fli.search", fromlist=["x"]).SearchParseError("x"), "parse_error"),+ (lambda: __import__("fli.search", fromlist=["x"]).SearchRejectedError(13), "rejected"),+ ],+ )+ def test_json_error_types(self, exc_factory, expected_type):+ from fli.cli.errors import json_error_payload++ _, error_type, _ = json_error_payload(exc_factory(), command="flights")+ assert error_type == expected_typediff --git a/tests/conftest.py b/tests/conftest.pyindex a3adcc8..02ea485 100644--- a/tests/conftest.py+++ b/tests/conftest.py@@ -1,5 +1,42 @@+from datetime import date, datetime+import pytest+from fli.models.google_flights import base as _base_models+from fli.models.google_flights import dates as _dates_models+++def pin_today(monkeypatch):+ """Return a callable that pins the library's notion of "today".++ Some fixtures — notably the ``tfs`` tokens Google itself issued for a+ specific query — bake in the travel dates they were captured with. Those+ dates cannot be made relative without invalidating the capture, yet the+ filter models refuse a travel date in the past, so the tests would start+ failing the day the capture aged out.++ Pinning the clock instead keeps the goldens byte-exact and makes the+ tests independent of the calendar date the suite runs on. Both modules+ that read the clock are patched: :mod:`fli.models.google_flights.dates`+ imports ``utc_today`` by name, so patching only ``base`` would leave its+ binding pointing at the real clock.++ Usage::++ @pytest.fixture(autouse=True)+ def _clock(pin_today):+ pin_today("2026-08-26")+ """++ def _pin(day: str | date) -> date:+ pinned = day if isinstance(day, date) else datetime.strptime(day, "%Y-%m-%d").date()+ for module in (_base_models, _dates_models):+ monkeypatch.setattr(module, "utc_today", lambda _pinned=pinned: _pinned)+ return pinned++ return _pin+def pytest_addoption(parser) -> None:"""Add options to pytest."""diff --git a/tests/core/test_builders.py b/tests/core/test_builders.pyindex 3d8fe43..5a582be 100644--- a/tests/core/test_builders.py+++ b/tests/core/test_builders.py@@ -3,6 +3,17 @@ import pytestfrom fli.core.builders import build_date_search_segments, build_flight_segments, normalize_datefrom fli.models import Airport, TripType+# The literal travel dates below are what these assertions are about, so pin+# the models' clock instead of letting the module start failing the day those+# dates fall into the past.+PINNED_TODAY = "2026-01-01"++[email protected](autouse=True)+def _pinned_clock(pin_today):+ """Freeze "today" well before every date literal in this module."""+ pin_today(PINNED_TODAY)+class TestNormalizeDate:"""Tests for normalize_date."""diff --git a/tests/mcp/test_mcp_server.py b/tests/mcp/test_mcp_server.pyindex 0656fe0..e9856c8 100644--- a/tests/mcp/test_mcp_server.py+++ b/tests/mcp/test_mcp_server.py@@ -1,7 +1,16 @@-"""Test MCP server functionality."""+"""Test MCP server functionality.++The four search tests below talk to Google for real, including from CI+runners. A transient search-page variant, a timeout or a hard rejection is a+property of the network that day rather than of this code, so+:func:`assert_live_search` reports those as skips — while every other failure,+and every assertion on the success path, still fails the build.+"""from datetime import datetime, timedelta+import pytest+from fli.mcp.server import (DateSearchParams,FlightSearchParams,@@ -19,6 +28,67 @@ def get_future_date(days: int = 30) -> str:return (datetime.now() + timedelta(days=days)).strftime("%Y-%m-%d")+# Phrases that only a transport-level failure produces: the page arrived+# without its payload, Google refused the call, or the request never completed.+# Each one is a literal string from `fli.search.exceptions` / `_tfs` / the+# client's error wrapper, not a generic word.+#+# Deliberately narrow on both sides. The MCP layer wraps every exception as+# "Search failed: ...", so matching that prefix would mask real bugs; and a+# bare "http" marker matched the `https://errors.pydantic.dev/...` URL that+# every pydantic ValidationError ends with, which would have skipped a decoder+# regression instead of failing it.+TRANSPORT_FAILURES = (+ "no ds:1 payload", # SearchParseError / the date sweep's _NO_PAYLOAD+ "declined the request", # SearchRejectedError (error 13)+ "timed out talking to google flights", # SearchTimeoutError+ "could not reach google flights", # SearchConnectionError+ "returned an error response", # SearchHTTPError (non-2xx status)+ "every date in the range failed", # the date sweep's total-failure error+ "no date in the range could be priced", # same, when the breaker tripped+)++# Phrases that mean we failed to understand a response we did receive. These+# must fail even though they can co-occur with transport wording.+PARSE_FAILURES = (+ "validationerror",+ "errors.pydantic.dev",+ "flight rows", # "Parsed 0/N flight rows …"+ "shape changed",+ "shape may have changed",+)+++def assert_live_search(result: dict, *, results_key: str, trip_type: str) -> None:+ """Assert a live search result's shape, skipping on transport failures.++ The error response shape carries no ``trip_type``/``count``, so asserting+ those unconditionally turns any transient failure into a red build. A+ decoder regression, on the other hand, must always fail — so a message that+ mentions parsing rows is never skipped, whatever else it says.+ """+ assert isinstance(result, dict)+ assert "success" in result+ assert results_key in result++ if not result["success"]:+ # Error shape: a non-empty message and an empty result list.+ assert "error" in result+ assert isinstance(result["error"], str) and result["error"]+ assert result[results_key] == []+ error = result["error"].lower()+ parse_failure = any(marker in error for marker in PARSE_FAILURES)+ transport_failure = any(marker in error for marker in TRANSPORT_FAILURES)+ if transport_failure and not parse_failure:+ pytest.skip(f"live search unavailable: {result['error']}")+ raise AssertionError(f"search failed for a non-transport reason: {result['error']}")++ assert "trip_type" in result, f"success response is missing trip_type: {sorted(result)}"+ assert result["trip_type"] == trip_type+ assert "count" in result+ assert isinstance(result[results_key], list)++class TestMCPServer:"""Test suite for MCP server tools."""@@ -35,15 +105,7 @@ class TestMCPServer:result = search_flights_fn(params)- assert isinstance(result, dict)- assert "success" in result- assert "flights" in result- assert "trip_type" in result-- if result["success"]:- assert result["trip_type"] == "ONE_WAY"- assert "count" in result- assert isinstance(result["flights"], list)+ assert_live_search(result, results_key="flights", trip_type="ONE_WAY")def test_search_flights_round_trip(self):"""Test round-trip flight search."""@@ -61,15 +123,7 @@ class TestMCPServer:result = search_flights_fn(params)- assert isinstance(result, dict)- assert "success" in result- assert "flights" in result- assert "trip_type" in result-- if result["success"]:- assert result["trip_type"] == "ROUND_TRIP"- assert "count" in result- assert isinstance(result["flights"], list)+ assert_live_search(result, results_key="flights", trip_type="ROUND_TRIP")def test_search_dates_one_way(self):"""Test one-way date search."""@@ -89,16 +143,9 @@ class TestMCPServer:result = search_dates_fn(params)- assert isinstance(result, dict)- assert "success" in result- assert "dates" in result- assert "trip_type" in result-+ assert_live_search(result, results_key="dates", trip_type="ONE_WAY")if result["success"]:- assert result["trip_type"] == "ONE_WAY"- assert "count" in resultassert "date_range" in result- assert isinstance(result["dates"], list)def test_search_dates_round_trip(self):"""Test round-trip date search."""@@ -121,17 +168,9 @@ class TestMCPServer:result = search_dates_fn(params)- assert isinstance(result, dict)- assert "success" in result- assert "dates" in result- assert "trip_type" in result-+ assert_live_search(result, results_key="dates", trip_type="ROUND_TRIP")if result["success"]:- assert result["trip_type"] == "ROUND_TRIP"- assert "count" in result- assert "duration" in resultassert result["duration"] == 7- assert isinstance(result["dates"], list)def test_invalid_airport_code(self):"""Test error handling for invalid airport code."""diff --git a/tests/mcp/test_mcp_server_unit.py b/tests/mcp/test_mcp_server_unit.pyindex bf4cf8a..6aefaf4 100644--- a/tests/mcp/test_mcp_server_unit.py+++ b/tests/mcp/test_mcp_server_unit.py@@ -25,6 +25,16 @@ from fli.mcp.server import (_serialize_layover,)+# The tool calls below pass fixed travel dates; pin the models' clock so they+# stay in the future no matter when the suite runs.+PINNED_TODAY = "2026-01-01"++[email protected](autouse=True)+def _pinned_clock(pin_today):+ """Freeze "today" well before every date literal in this module."""+ pin_today(PINNED_TODAY)+def _make_raiser(exc: BaseException):"""Return a callable that unconditionally raises ``exc``."""@@ -603,3 +613,224 @@ class TestExecuteBookingOptions:assert "booking_url" in resultassert "note" in resultassert "booking_url" in result["note"]+++class TestDateSearchCapSurfacing:+ """The per-search date cap reaches the MCP caller as a plain error string."""++ def test_over_the_cap_returns_a_readable_error(self):+ from fli.mcp.server import DateSearchParams, _execute_date_search++ params = DateSearchParams(+ origin="JFK",+ destination="LHR",+ start_date="2026-02-01",+ end_date="2026-12-01",+ )+ result = _execute_date_search(params)++ assert result["success"] is False+ assert "93-date limit" in result["error"]+ assert result["dates"] == []++ def test_budget_window_prompt_default_range_fits_under_the_cap(self):+ """The prompt's default window must not suggest an over-cap search."""+ from datetime import datetime++ from fli.mcp.server import find_budget_window_prompt+ from fli.search.dates import MAX_DATES_PER_SEARCH++ text = find_budget_window_prompt(origin="JFK", destination="LHR")+ start_s, end_s = text.split("for trips between ")[1].split(". ")[0].split(" and ")+ start = datetime.strptime(start_s.strip(), "%Y-%m-%d")+ end = datetime.strptime(end_s.strip(), "%Y-%m-%d")+ assert (end - start).days + 1 <= MAX_DATES_PER_SEARCH+++class TestLiveSearchAssertionHelper:+ """`assert_live_search` must skip transport failures and fail real ones."""++ @staticmethod+ def _failure(message: str) -> dict:+ return {"success": False, "error": f"Search failed: {message}", "flights": []}++ @pytest.mark.parametrize(+ "message",+ [+ # Every string below is produced verbatim by the library today.+ "Search page carried no ds:1 payload — Google may have changed the "+ "page shape, or served a consent/blocked page instead.",+ "Google Flights declined the request (error 13) and returned no data.",+ "Timed out talking to Google Flights (www.google.com).",+ "Could not reach Google Flights (www.google.com).",+ "Google Flights returned an error response (HTTP 429).",+ "Priced 0 of 8 dates — every date in the range failed. Reasons: …",+ ],+ ids=["no-payload", "rejected", "timeout", "connection", "http-429", "sweep-total"],+ )+ def test_real_transport_messages_skip(self, message):+ import _pytest.outcomes++ from tests.mcp.test_mcp_server import assert_live_search++ with pytest.raises(_pytest.outcomes.Skipped):+ assert_live_search(self._failure(message), results_key="flights", trip_type="ONE_WAY")++ @pytest.mark.parametrize(+ "message",+ [+ # A pydantic ValidationError always ends with this URL. The old+ # rule matched the bare substring "http" inside it and skipped.+ "1 validation error for FlightLeg\narrival_datetime\n Input should be a "+ "valid datetime [type=datetime_type]\n For further information visit "+ "https://errors.pydantic.dev/2.11/v/datetime_type",+ "Parsed 0/20 flight rows — Google response shape may have changed "+ "(sample reasons: ValueError: price field is not numeric)",+ "Shopping response shape changed — no flights array at inner[2]/[3]: "+ "list index out of range",+ "TypeError: 'NoneType' object is not subscriptable",+ ],+ ids=["pydantic-url", "zero-rows-parsed", "shape-changed", "type-error"],+ )+ def test_parse_and_code_failures_still_fail(self, message):+ """A decoder regression must never hide behind the transport skip."""+ from tests.mcp.test_mcp_server import assert_live_search++ with pytest.raises(AssertionError, match="non-transport reason"):+ assert_live_search(self._failure(message), results_key="flights", trip_type="ONE_WAY")++ def test_parse_wording_wins_over_transport_wording(self):+ """Mentioning both must fail, not skip — the parse half is the real news."""+ from tests.mcp.test_mcp_server import assert_live_search++ message = (+ "Search page carried no ds:1 payload; also 1 validation error for "+ "FlightLeg, see https://errors.pydantic.dev/2.11/v/datetime_type"+ )+ with pytest.raises(AssertionError, match="non-transport reason"):+ assert_live_search(self._failure(message), results_key="flights", trip_type="ONE_WAY")++ def test_wrong_success_shape_fails(self):+ from tests.mcp.test_mcp_server import assert_live_search++ with pytest.raises(AssertionError):+ assert_live_search(+ {"success": True, "flights": [], "count": 0}, # no trip_type at all+ results_key="flights",+ trip_type="ONE_WAY",+ )++ def test_success_path_is_strict(self):+ from tests.mcp.test_mcp_server import assert_live_search++ assert_live_search(+ {"success": True, "flights": [], "trip_type": "ONE_WAY", "count": 0},+ results_key="flights",+ trip_type="ONE_WAY",+ )+ with pytest.raises(AssertionError):+ assert_live_search(+ {"success": True, "flights": [], "trip_type": "ROUND_TRIP", "count": 0},+ results_key="flights",+ trip_type="ONE_WAY",+ )++ def test_transport_failure_is_a_skip(self):+ import _pytest.outcomes++ from tests.mcp.test_mcp_server import assert_live_search++ with pytest.raises(_pytest.outcomes.Skipped):+ assert_live_search(+ {+ "success": False,+ "error": "Search failed: Search page carried no ds:1 payload",+ "flights": [],+ },+ results_key="flights",+ trip_type="ONE_WAY",+ )++ def test_other_failures_still_fail(self):+ """A genuine bug must not hide behind the skip."""+ from tests.mcp.test_mcp_server import assert_live_search++ with pytest.raises(AssertionError, match="non-transport reason"):+ assert_live_search(+ {+ "success": False,+ "error": "Search failed: TypeError: 'NoneType' is not subscriptable",+ "flights": [],+ },+ results_key="flights",+ trip_type="ONE_WAY",+ )+++class TestSearchErrorMessage:+ """MCP callers have no log file, so the hint has to be in the response."""++ def test_parse_error_carries_the_consent_hint(self):+ from fli.mcp.server import _search_error_message+ from fli.search import SearchParseError++ message = _search_error_message(SearchParseError("Search page carried no ds:1 payload."))+ assert message.startswith("Search failed: ")+ assert "ds:1" in message+ assert "FLI_SOCS_COOKIE" in message++ def test_rejected_error_is_passed_through(self):+ from fli.mcp.server import _search_error_message+ from fli.search import SearchRejectedError++ message = _search_error_message(SearchRejectedError(13))+ assert "declined the request" in message+ assert "FLI_SOCS_COOKIE" not in message++ def test_other_errors_keep_the_plain_shape(self):+ from fli.mcp.server import _search_error_message++ assert _search_error_message(ValueError("boom")) == "Search failed: boom"++ def test_prefix_is_configurable(self):+ from fli.mcp.server import _search_error_message++ assert _search_error_message(ValueError("boom"), "Booking lookup failed") == (+ "Booking lookup failed: boom"+ )++ def test_the_hint_survives_assert_live_search(self):+ """The hint must not turn a transport skip into a failure."""+ import _pytest.outcomes++ from fli.mcp.server import _search_error_message+ from fli.search import SearchParseError+ from tests.mcp.test_mcp_server import assert_live_search++ error = _search_error_message(SearchParseError("Search page carried no ds:1 payload."))+ with pytest.raises(_pytest.outcomes.Skipped):+ assert_live_search(+ {"success": False, "error": error, "flights": []},+ results_key="flights",+ trip_type="ONE_WAY",+ )+++class TestTrippedSweepErrorIsRecognised:+ """The breaker's error text must reach the live tests as a transport failure."""++ def test_both_sweep_failure_wordings_skip(self):+ import _pytest.outcomes++ from tests.mcp.test_mcp_server import assert_live_search++ for message in (+ "Priced 0 of 30 dates — every date in the range failed. Reasons: …",+ "Priced 0 of 30 dates — no date in the range could be priced. Reasons: …",+ ):+ with pytest.raises(_pytest.outcomes.Skipped):+ assert_live_search(+ {"success": False, "error": f"Search failed: {message}", "dates": []},+ results_key="dates",+ trip_type="ONE_WAY",+ )diff --git a/tests/search/_pages.py b/tests/search/_pages.pynew file mode 100644index 0000000..2c9eaa1--- /dev/null+++ b/tests/search/_pages.py@@ -0,0 +1,20 @@+"""Helper for building the search-page bodies the transport now parses.++Since the move to the public ``/travel/flights`` page, the client reads its+payload out of an ``AF_initDataCallback`` blob keyed ``ds:1`` rather than a+``wrb.fr`` RPC body. Tests that fake a response wrap their payload here.+"""++from __future__ import annotations++import json+from typing import Any+++def as_search_page(payload: Any) -> str:+ """Wrap ``payload`` as the ``ds:1`` blob of a rendered search page."""+ return (+ "<script>AF_initDataCallback({key: 'ds:1', hash: '1', data:"+ + json.dumps(payload, separators=(",", ":"))+ + ", sideChannel: {}});</script>"+ )diff --git a/tests/search/fixtures/search_page_jfk_lhr_nonstop_ds1.html b/tests/search/fixtures/search_page_jfk_lhr_nonstop_ds1.htmlnew file mode 100644index 0000000..69cd649--- /dev/null+++ b/tests/search/fixtures/search_page_jfk_lhr_nonstop_ds1.html@@ -0,0 +1,14 @@+<!doctype html>+<html><head><meta charset="utf-8">+<title>Google Flights search page — ds:1 capture</title>+</head><body>+<!--+ Captured 2026-09-20 from+ https://www.google.com/travel/flights?tfs=<JFK->LHR non-stop, 2026-10-25>&hl=en&gl=US&curr=USD+ Only the as-served ds:1 AF_initDataCallback script block is kept; the+ surrounding ~2.4 MB of markup, styles and other ds:* blobs are dropped.+ No cookies or account-specific data are present (the request carried+ only the public SOCS consent cookie).+-->+<script nonce="REDACTED">AF_initDataCallback({key: 'ds:1', hash: '9', data:[[null,[[1789895299889603,16322849,2149534736],null,null,null,null,[[1]]],0,"g6KvaoOmNqGi5LcPkJj9gAg","HMh4cKofzVAoAIr5YgBG--------pfbkr16AAAAAGqvooMNZQMmA"],[[[[["JFK",0],"John F. Kennedy International Airport",["/m/02_286","New York",[["https://encrypted-tbn1.gstatic.com/images?q\u003dtbn:ANd9GcQEaUa9NsdPWGpAUGkTApkZDT_4M6_6V8wTcC0v1b1wJAJX-BuMSiipXbsoznGgcI1xLOc5QiTcR_xovexgjdOz0gqQe0tRQ9h0bUkZ07Q"],["https://encrypted-tbn1.gstatic.com/images?q\u003dtbn:ANd9GcRa1dwH1NZQk4dsbPiyA9Vrq2RX75jXSZ-OkHn7NkLHl-11HercqDXoZ4p2cDxJkH6vca2degawrCzHEQ"]]],[40.6397222,-73.778889],"US",0,"United States"]],[[["LHR",0],"Heathrow Airport",["/m/04jpl","London",[["https://encrypted-tbn1.gstatic.com/images?q\u003dtbn:ANd9GcQYH83YXny8hR4M7k5BMFq4vUT6LNtVABQzgs2pg-hcpSZq3oMBOQK3xh591AAJv2Qx4uvFZUGqOVt4kuoCUOklISunmndJleOoSef_7QE"],["https://encrypted-tbn1.gstatic.com/images?q\u003dtbn:ANd9GcRpN9RbtOSTDqKIPxWc_D6rdSysaWVh6d-NW7yz7yFXKRwh5RN5BpNIoXEwH1XVcFdLWqn6Sm8_Y_zmeg"]]],[51.4775,-0.4613889],"GB",0,"United Kingdom"]]]],[[[["B6",["JetBlue"],[[null,null,null,"JFK","John F. Kennedy International Airport","Heathrow Airport","LHR",null,[9,45],null,[20,55],430,[null,1,null,null,null,null,null,null,null,1,null,2],3,"32 in",null,1,"Airbus A321neo",null,0,[2026,10,25],[2026,10,25],["B6","1107",null,"JetBlue"],null,null,1,null,null,null,null,"32 inches",589753,2]],"JFK",[2026,10,25],[9,45],"LHR",[2026,10,25],[20,55],430,null,null,0,null,null,null,null,"RkR6U",[[1789895299889603,16322849,2149534736],null,null,null,null,[[2]]],1,null,null,[null,null,3,37,null,1,1,590000,430000,null,394000,3,0,null,null,2,null,6],[1],[["B6","JetBlue","https://www.jetblue.com/at-the-airport/accessibility-assistance"]]],[[null,295],"CjRITWg0Y0tvZnpWQW9BSXI1WWdCRy0tLS0tLS0tcGZia3IxNkFBQUFBR3F2b29NTlpRTW1BEgZCNjExMDcaCwiK5gEQAhoDVVNEOB1wiuYB"],null,1,[null,null,null,null,1,null,[null,1]],[0,0,0],0,[],"[\"CAISA1VTRBoECIrmASJvClgKVgoDSkZLEhkyMDI2LTEwLTI1VDA5OjQ1OjAwLTA0OjAwGgNMSFIiFDIwMjYtMTAtMjVUMjA6NTU6MDBaKgJCNjIEMTEwNzoCQjZCBDExMDdIAVIDMzJREgQIAxABGAEoADIJCgdKZXRCbHVl\"]",[[2]],0],[["AA",["American"],[[null,null,null,"JFK","John F. Kennedy International Airport","Heathrow Airport","LHR",null,[19,15],1,[6,20],425,[null,1,null,null,null,null,null,null,null,1,null,3],1,"31 in",[["BA","1511",null,"British Airways"],["IB","4218",null,"Iberia"],["AY","3772",null,"Finnair"]],1,"Boeing 777",[1],0,[2026,10,25],[2026,10,26],["AA","100",null,"American"],null,null,1,null,null,null,null,"31 inches",414901,2]],"JFK",[2026,10,25],[19,15],"LHR",[2026,10,26],[6,20],425,1,null,0,null,null,null,["British Airways","Iberia","Finnair"],"VEHZwe",[[1789895299889603,16322849,2149534736],null,null,null,null,[[3]]],1,null,null,[null,null,2,-3,null,1,1,415000,430000,null,394000,2,0,null,null,2,null,5],[1],[["AA","American","https://www.aa.com/i18n/travel-info/special-assistance/special-assistance.jsp"]]],[[null,295],"CjRITWg0Y0tvZnpWQW9BSXI1WWdCRy0tLS0tLS0tcGZia3IxNkFBQUFBR3F2b29NTlpRTW1BEgVBQTEwMBoLCIrmARACGgNVU0Q4HXCK5gE\u003d"],null,1,[null,null,null,null,1,null,[null,1]],[0,0,0],0,[],"[\"CAISA1VTRBoECIrmASKQAQpWClQKA0pGSxIZMjAyNi0xMC0yNVQxOToxNTowMC0wNDowMBoDTEhSIhQyMDI2LTEwLTI2VDA2OjIwOjAwWioCQUEyAzEwMDoCQUFCAzEwMEgBUgM3N1cSBAgDEAEYASgAMiwKCEFtZXJpY2FuCg9Ccml0aXNoIEFpcndheXMKBkliZXJpYQoHRmlubmFpcg\\u003d\\u003d\"]",null,0],[["DL",["Delta"],[[null,null,null,"JFK","John F. Kennedy International Airport","Heathrow Airport","LHR",null,[21],1,[8,5],425,[null,1,null,null,null,null,null,null,null,1,null,2],1,"31 in",[["KL","6101",null,"KLM"],["VS","4000",null,"Virgin Atlantic"]],1,"Boeing 767",[1],0,[2026,10,25],[2026,10,26],["DL","1",null,"Delta"],null,null,1,null,null,null,null,"31 inches",323091,2]],"JFK",[2026,10,25],[21],"LHR",[2026,10,26],[8,5],425,1,null,0,null,null,null,["KLM","Virgin Atlantic"],"Ih6zzf",[[1789895299889603,16322849,2149534736],null,null,null,null,[[4]]],1,null,null,[null,null,1,-25,null,1,1,323000,430000,[null,1],394000,1,0,null,null,2,null,4],[1],[["DL","Delta","https://www.delta.com/us/en/accessible-travel-services/overview"]]],[[null,295],"CjRITWg0Y0tvZnpWQW9BSXI1WWdCRy0tLS0tLS0tcGZia3IxNkFBQUFBR3F2b29NTlpRTW1BEgNETDEaCwiK5gEQAhoDVVNEOB1wiuYB"],null,1,[null,null,null,null,1,null,[null,1]],[0,0,0],0,[],"[\"CAISA1VTRBoECIrmASJ9ClIKUAoDSkZLEhkyMDI2LTEwLTI1VDIxOjAwOjAwLTA0OjAwGgNMSFIiFDIwMjYtMTAtMjZUMDg6MDU6MDBaKgJETDIBMToCRExCATFIAVIDNzY0EgQIAxABGAEoADIdCgVEZWx0YQoDS0xNCg9WaXJnaW4gQXRsYW50aWM\\u003d\"]",[[1]],0]],null,0,0,[1]],[[[["B6",["JetBlue"],[[null,null,null,"JFK","John F. Kennedy International Airport","Heathrow Airport","LHR",null,[22,3],1,[9,30],447,[null,1,null,null,null,null,null,null,null,1,null,2],3,"32 in",[["TP","4442",null,"Tap Air Portugal"]],1,"Airbus A321neo",[1],0,[2026,10,25],[2026,10,26],["B6","7",null,"JetBlue"],null,null,1,null,null,null,null,"32 inches",589753,2]],"JFK",[2026,10,25],[22,3],"LHR",[2026,10,26],[9,30],447,1,null,0,null,null,null,["Tap Air Portugal"],"IQNDif",[[1789895299889603,16322849,2149534736],null,null,null,null,[[5]]],1,null,null,[null,null,3,37,null,1,1,590000,430000,null,394000,3,0,null,null,2,null,6],[1],[["B6","JetBlue","https://www.jetblue.com/at-the-airport/accessibility-assistance"]]],[[null,295],"CjRITWg0Y0tvZnpWQW9BSXI1WWdCRy0tLS0tLS0tcGZia3IxNkFBQUFBR3F2b29NTlpRTW1BEgNCNjcaCwiK5gEQAhoDVVNEOB1wiuYB"],null,1,[null,null,null,null,1,null,[null,1]],[0,0,0],0,[],"[\"CAISA1VTRBoECIrmASJ7ClIKUAoDSkZLEhkyMDI2LTEwLTI1VDIyOjAzOjAwLTA0OjAwGgNMSFIiFDIwMjYtMTAtMjZUMDk6MzA6MDBaKgJCNjIBNzoCQjZCATdIAVIDMzJREgQIAxABGAEoADIbCgdKZXRCbHVlChBUYXAgQWlyIFBvcnR1Z2Fs\"]",[[2]],0],[["AA",["American"],[[null,null,null,"JFK","John F. Kennedy International Airport","Heathrow Airport","LHR",null,[22,5],1,[9,15],430,[null,1,null,null,null,null,null,null,null,1,null,2],1,"31 in",[["BA","1515",null,"British Airways"],["IB","4220",null,"Iberia"],["AY","3774",null,"Finnair"]],1,"Boeing 787",[1],0,[2026,10,25],[2026,10,26],["AA","104",null,"American"],null,null,1,null,null,null,null,"31 inches",311194,2]],"JFK",[2026,10,25],[22,5],"LHR",[2026,10,26],[9,15],430,1,null,0,null,null,null,["British Airways","Iberia","Finnair"],"SX8ID",[[1789895299889603,16322849,2149534736],null,null,null,null,[[6]]],1,null,null,[null,null,1,-28,null,1,1,311000,430000,[1],394000,1,0,null,null,2,null,4],[1],[["AA","American","https://www.aa.com/i18n/travel-info/special-assistance/special-assistance.jsp"]]],[[null,295],"CjRITWg0Y0tvZnpWQW9BSXI1WWdCRy0tLS0tLS0tcGZia3IxNkFBQUFBR3F2b29NTlpRTW1BEgVBQTEwNBoLCIrmARACGgNVU0Q4HXCK5gE\u003d"],null,1,[null,null,null,null,1,null,[null,1]],[0,0,0],0,[],"[\"CAISA1VTRBoECIrmASKQAQpWClQKA0pGSxIZMjAyNi0xMC0yNVQyMjowNTowMC0wNDowMBoDTEhSIhQyMDI2LTEwLTI2VDA5OjE1OjAwWioCQUEyAzEwNDoCQUFCAzEwNEgBUgM3ODkSBAgDEAEYASgAMiwKCEFtZXJpY2FuCg9Ccml0aXNoIEFpcndheXMKBkliZXJpYQoHRmlubmFpcg\\u003d\\u003d\"]",[[1]],0],[["DL",["Delta"],[[null,null,null,"JFK","John F. Kennedy International Airport","Heathrow Airport","LHR",null,[23,20],1,[10,30],430,[null,1,null,null,null,null,null,null,null,1,null,2],1,"31 in",[["KL","6103",null,"KLM"],["VS","4030",null,"Virgin Atlantic"]],1,"Boeing 767",[1,1],0,[2026,10,25],[2026,10,26],["DL","3",null,"Delta"],null,null,1,null,null,null,null,"31 inches",323091,2]],"JFK",[2026,10,25],[23,20],"LHR",[2026,10,26],[10,30],430,1,null,0,null,null,null,["KLM","Virgin Atlantic"],"ipBmOd",[[1789895299889603,16322849,2149534736],null,null,null,null,[[7]]],1,null,null,[null,null,1,-25,null,1,1,323000,430000,[null,1],394000,1,0,null,null,2,null,4],[1],[["DL","Delta","https://www.delta.com/us/en/accessible-travel-services/overview"]]],[[null,295],"CjRITWg0Y0tvZnpWQW9BSXI1WWdCRy0tLS0tLS0tcGZia3IxNkFBQUFBR3F2b29NTlpRTW1BEgNETDMaCwiK5gEQAhoDVVNEOB1wiuYB"],null,1,[null,null,null,null,1,null,[null,1]],[0,0,0],0,[],"[\"CAISA1VTRBoECIrmASJ9ClIKUAoDSkZLEhkyMDI2LTEwLTI1VDIzOjIwOjAwLTA0OjAwGgNMSFIiFDIwMjYtMTAtMjZUMTA6MzA6MDBaKgJETDIBMzoCRExCATNIAVIDNzY0EgQIAxABGAEoADIdCgVEZWx0YQoDS0xNCg9WaXJnaW4gQXRsYW50aWM\\u003d\"]",[[1]],0],[["BA",["British Airways"],[[null,null,null,"JFK","John F. Kennedy International Airport","Heathrow Airport","LHR",null,[null,20],null,[11,10],410,[null,1,null,null,null,null,null,null,null,1,null,3],1,"31 in",[["AA","6941",null,"American"],["IB","3566",null,"Iberia"],["AY","5482",null,"Finnair"]],1,"Boeing 787-10",[1,1],0,[2026,10,25],[2026,10,25],["BA","182",null,"British Airways"],null,null,1,null,null,null,null,"31 inches",304024,2]],"JFK",[2026,10,25],[null,20],"LHR",[2026,10,25],[11,10],410,null,null,0,null,null,null,["American","Iberia","Finnair"],"QPzLib",[[1789895299889603,16322849,2149534736],null,null,null,null,[[8]]],1,null,null,[null,null,1,-29,null,1,1,304000,430000,[1],394000,1,0,null,null,2,null,4],[1],[["BA","British Airways","https://www.britishairways.com/en-gb/information/travel-assistance"]]],[[null,368],"CjRITWg0Y0tvZnpWQW9BSXI1WWdCRy0tLS0tLS0tcGZia3IxNkFBQUFBR3F2b29NTlpRTW1BEgVCQTE4MhoLCI6fAhACGgNVU0Q4HXCOnwI\u003d"],null,0,[null,null,null,null,1,null,[null,1]],[0,0,0],0,[],"[\"CAISA1VTRBoECI6fAiKQAQpWClQKA0pGSxIZMjAyNi0xMC0yNVQwMDoyMDowMC0wNDowMBoDTEhSIhQyMDI2LTEwLTI1VDExOjEwOjAwWioCQkEyAzE4MjoCQkFCAzE4MkgBUgM3ODESBAgDEAEYASgAMiwKD0JyaXRpc2ggQWlyd2F5cwoIQW1lcmljYW4KBkliZXJpYQoHRmlubmFpcg\\u003d\\u003d\"]",[[1]],0],[["VS",["Virgin Atlantic"],[[null,null,null,"JFK","John F. Kennedy International Airport","Heathrow Airport","LHR",null,[9],null,[20,10],430,[null,1,null,null,null,null,null,null,null,1,null,3],1,"31 in",[["AF","9656",null,"Air France"],["DL","5996",null,"Delta"],["KL","2505",null,"KLM"]],1,"Boeing 787",null,0,[2026,10,25],[2026,10,25],["VS","26",null,"Virgin Atlantic"],null,null,1,null,null,null,null,"31 inches",372334,2]],"JFK",[2026,10,25],[9],"LHR",[2026,10,25],[20,10],430,null,null,0,null,null,null,["Air France","Delta","KLM"],"xN8cVb",[[1789895299889603,16322849,2149534736],null,null,null,null,[[9]]],1,null,null,[null,null,1,-13,null,1,1,372000,430000,null,394000,1,0,null,null,2,null,4],[1],[["VS","Virgin Atlantic","https://help.virginatlantic.com/gb/en/special-assistance.html"]]],[[null,368],"CjRITWg0Y0tvZnpWQW9BSXI1WWdCRy0tLS0tLS0tcGZia3IxNkFBQUFBR3F2b29NTlpRTW1BEgRWUzI2GgsIjp8CEAIaA1VTRDgdcI6fAg\u003d\u003d"],null,0,[null,null,null,null,1,null,[null,1]],[0,0,0],0,[],"[\"CAISA1VTRBoECI6fAiKLAQpUClIKA0pGSxIZMjAyNi0xMC0yNVQwOTowMDowMC0wNDowMBoDTEhSIhQyMDI2LTEwLTI1VDIwOjEwOjAwWioCVlMyAjI2OgJWU0ICMjZIAVIDNzg5EgQIAxABGAEoADIpCg9WaXJnaW4gQXRsYW50aWMKCkFpciBGcmFuY2UKBURlbHRhCgNLTE0\\u003d\"]",[[1]],0],[["BA",["British Airways"],[[null,null,null,"JFK","John F. Kennedy International Airport","Heathrow Airport","LHR",null,[9,5],null,[20],415,[null,null,null,null,null,1,null,null,null,1,null,3],1,"31 in",[["AA","6939",null,"American"],["IB","3564",null,"Iberia"],["AY","5478",null,"Finnair"]],1,"Boeing 777",null,0,[2026,10,25],[2026,10,25],["BA","178",null,"British Airways"],null,null,1,null,null,null,null,"31 inches",432950,2]],"JFK",[2026,10,25],[9,5],"LHR",[2026,10,25],[20],415,null,null,0,null,null,null,["American","Iberia","Finnair"],"FDkI3b",[[1789895299889603,16322849,2149534736],null,null,null,null,[[10]]],1,null,null,[null,null,2,1,null,1,1,433000,430000,null,394000,3,0,null,null,2,null,5],[1],[["BA","British Airways","https://www.britishairways.com/en-gb/information/travel-assistance"]]],[[null,368],"CjRITWg0Y0tvZnpWQW9BSXI1WWdCRy0tLS0tLS0tcGZia3IxNkFBQUFBR3F2b29NTlpRTW1BEgVCQTE3OBoLCI6fAhACGgNVU0Q4HXCOnwI\u003d"],null,0,[null,null,null,null,1,null,[null,1]],[0,0,0],0,[],"[\"CAISA1VTRBoECI6fAiKQAQpWClQKA0pGSxIZMjAyNi0xMC0yNVQwOTowNTowMC0wNDowMBoDTEhSIhQyMDI2LTEwLTI1VDIwOjAwOjAwWioCQkEyAzE3ODoCQkFCAzE3OEgBUgM3NzcSBAgDEAEYASgAMiwKD0JyaXRpc2ggQWlyd2F5cwoIQW1lcmljYW4KBkliZXJpYQoHRmlubmFpcg\\u003d\\u003d\"]",null,0],[["AA",["American"],[[null,null,null,"JFK","John F. Kennedy International Airport","Heathrow Airport","LHR",null,[11,5],null,[22,10],425,[null,1,null,null,null,null,null,null,null,1,null,3],1,"31 in",[["BA","1594",null,"British Airways"],["IB","4614",null,"Iberia"],["AY","3787",null,"Finnair"]],1,"Boeing 777",null,0,[2026,10,25],[2026,10,25],["AA","142",null,"American"],null,null,1,null,null,null,null,"31 inches",405224,2]],"JFK",[2026,10,25],[11,5],"LHR",[2026,10,25],[22,10],425,null,null,0,null,null,null,["British Airways","Iberia","Finnair"],"uSrIee",[[1789895299889603,16322849,2149534736],null,null,null,null,[[11]]],1,null,null,[null,null,1,-6,null,1,1,405000,430000,null,394000,2,0,null,null,2,null,4],[1],[["AA","American","https://www.aa.com/i18n/travel-info/special-assistance/special-assistance.jsp"]]],[[null,368],"CjRITWg0Y0tvZnpWQW9BSXI1WWdCRy0tLS0tLS0tcGZia3IxNkFBQUFBR3F2b29NTlpRTW1BEgVBQTE0MhoLCI6fAhACGgNVU0Q4HXCOnwI\u003d"],null,0,[null,null,null,null,1,null,[null,1]],[0,0,0],0,[],"[\"CAISA1VTRBoECI6fAiKQAQpWClQKA0pGSxIZMjAyNi0xMC0yNVQxMTowNTowMC0wNDowMBoDTEhSIhQyMDI2LTEwLTI1VDIyOjEwOjAwWioCQUEyAzE0MjoCQUFCAzE0MkgBUgM3NzISBAgDEAEYASgAMiwKCEFtZXJpY2FuCg9Ccml0aXNoIEFpcndheXMKBkliZXJpYQoHRmlubmFpcg\\u003d\\u003d\"]",[[1]],0],[["BA",["British Airways"],[[null,null,null,"JFK","John F. Kennedy International Airport","Heathrow Airport","LHR",null,[18,50],1,[5,50],420,[null,null,null,null,null,1,null,null,null,1,null,3],1,"31 in",[["AA","6881",null,"American"],["IB","3773",null,"Iberia"],["AY","5408",null,"Finnair"]],1,"Boeing 777",[1],0,[2026,10,25],[2026,10,26],["BA","180",null,"British Airways"],null,null,1,null,null,null,null,"31 inches",394325,2]],"JFK",[2026,10,25],[18,50],"LHR",[2026,10,26],[5,50],420,1,null,0,null,null,null,["American","Iberia","Finnair"],"HX0wSd",[[1789895299889603,16322849,2149534736],null,null,null,null,[[12]]],1,null,null,[null,null,1,-8,null,1,1,394000,430000,null,394000,2,0,null,null,2,null,4],[1],[["BA","British Airways","https://www.britishairways.com/en-gb/information/travel-assistance"]]],[[null,368],"CjRITWg0Y0tvZnpWQW9BSXI1WWdCRy0tLS0tLS0tcGZia3IxNkFBQUFBR3F2b29NTlpRTW1BEgVCQTE4MBoLCI6fAhACGgNVU0Q4HXCOnwI\u003d"],null,0,[null,null,null,null,1,null,[null,1]],[0,0,0],0,[],"[\"CAISA1VTRBoECI6fAiKQAQpWClQKA0pGSxIZMjAyNi0xMC0yNVQxODo1MDowMC0wNDowMBoDTEhSIhQyMDI2LTEwLTI2VDA1OjUwOjAwWioCQkEyAzE4MDoCQkFCAzE4MEgBUgM3N1cSBAgDEAEYASgAMiwKD0JyaXRpc2ggQWlyd2F5cwoIQW1lcmljYW4KBkliZXJpYQoHRmlubmFpcg\\u003d\\u003d\"]",[[1]],0],[["BA",["British Airways"],[[null,null,null,"JFK","John F. Kennedy International Airport","Heathrow Airport","LHR",null,[19,10],1,[6,15],425,[null,null,null,null,null,1,null,null,null,1,null,3],1,"31 in",[["AA","6925",null,"American"],["IB","3540",null,"Iberia"],["AY","5512",null,"Finnair"]],1,"Boeing 777",[1],0,[2026,10,25],[2026,10,26],["BA","112",null,"British Airways"],null,null,1,null,null,null,null,"31 inches",432950,2]],"JFK",[2026,10,25],[19,10],"LHR",[2026,10,26],[6,15],425,1,null,0,null,null,null,["American","Iberia","Finnair"],"CtMiAd",[[1789895299889603,16322849,2149534736],null,null,null,null,[[13]]],1,null,null,[null,null,2,1,null,1,1,433000,430000,null,394000,3,0,null,null,2,null,5],[1],[["BA","British Airways","https://www.britishairways.com/en-gb/information/travel-assistance"]]],[[null,368],"CjRITWg0Y0tvZnpWQW9BSXI1WWdCRy0tLS0tLS0tcGZia3IxNkFBQUFBR3F2b29NTlpRTW1BEgVCQTExMhoLCI6fAhACGgNVU0Q4HXCOnwI\u003d"],null,0,[null,null,null,null,1,null,[null,1]],[0,0,0],0,[],"[\"CAISA1VTRBoECI6fAiKQAQpWClQKA0pGSxIZMjAyNi0xMC0yNVQxOToxMDowMC0wNDowMBoDTEhSIhQyMDI2LTEwLTI2VDA2OjE1OjAwWioCQkEyAzExMjoCQkFCAzExMkgBUgM3NzcSBAgDEAEYASgAMiwKD0JyaXRpc2ggQWlyd2F5cwoIQW1lcmljYW4KBkliZXJpYQoHRmlubmFpcg\\u003d\\u003d\"]",null,0],[["BA",["British Airways"],[[null,null,null,"JFK","John F. Kennedy International Airport","Heathrow Airport","LHR",null,[19,40],1,[6,40],420,[null,null,null,null,null,1,null,null,null,1,null,3],1,"31 in",[["AA","6923",null,"American"],["IB","3560",null,"Iberia"],["AY","5474",null,"Finnair"]],1,"Boeing 777",[1],0,[2026,10,25],[2026,10,26],["BA","174",null,"British Airways"],null,null,1,null,null,null,null,"31 inches",394325,2]],"JFK",[2026,10,25],[19,40],"LHR",[2026,10,26],[6,40],420,1,null,0,null,null,null,["American","Iberia","Finnair"],"crvUtf",[[1789895299889603,16322849,2149534736],null,null,null,null,[[14]]],1,null,null,[null,null,1,-8,null,1,1,394000,430000,null,394000,2,0,null,null,2,null,4],[1],[["BA","British Airways","https://www.britishairways.com/en-gb/information/travel-assistance"]]],[[null,368],"CjRITWg0Y0tvZnpWQW9BSXI1WWdCRy0tLS0tLS0tcGZia3IxNkFBQUFBR3F2b29NTlpRTW1BEgVCQTE3NBoLCI6fAhACGgNVU0Q4HXCOnwI\u003d"],null,0,[null,null,null,null,1,null,[null,1]],[0,0,0],0,[],"[\"CAISA1VTRBoECI6fAiKQAQpWClQKA0pGSxIZMjAyNi0xMC0yNVQxOTo0MDowMC0wNDowMBoDTEhSIhQyMDI2LTEwLTI2VDA2OjQwOjAwWioCQkEyAzE3NDoCQkFCAzE3NEgBUgM3N1cSBAgDEAEYASgAMiwKD0JyaXRpc2ggQWlyd2F5cwoIQW1lcmljYW4KBkliZXJpYQoHRmlubmFpcg\\u003d\\u003d\"]",[[1]],0],[["BA",["British Airways"],[[null,null,null,"JFK","John F. Kennedy International Airport","Heathrow Airport","LHR",null,[20,5],1,[7,5],420,[null,null,null,null,null,1,null,null,null,1,null,3],1,"31 in",[["AA","6937",null,"American"],["IB","3562",null,"Iberia"],["AY","5476",null,"Finnair"]],1,"Boeing 777",[1],0,[2026,10,25],[2026,10,26],["BA","176",null,"British Airways"],null,null,1,null,null,null,null,"31 inches",432950,2]],"JFK",[2026,10,25],[20,5],"LHR",[2026,10,26],[7,5],420,1,null,0,null,null,null,["American","Iberia","Finnair"],"E5x7Uc",[[1789895299889603,16322849,2149534736],null,null,null,null,[[15]]],1,null,null,[null,null,2,1,null,1,1,433000,430000,null,394000,3,0,null,null,2,null,5],[1],[["BA","British Airways","https://www.britishairways.com/en-gb/information/travel-assistance"]]],[[null,368],"CjRITWg0Y0tvZnpWQW9BSXI1WWdCRy0tLS0tLS0tcGZia3IxNkFBQUFBR3F2b29NTlpRTW1BEgVCQTE3NhoLCI6fAhACGgNVU0Q4HXCOnwI\u003d"],null,0,[null,null,null,null,1,null,[null,1]],[0,0,0],0,[],"[\"CAISA1VTRBoECI6fAiKQAQpWClQKA0pGSxIZMjAyNi0xMC0yNVQyMDowNTowMC0wNDowMBoDTEhSIhQyMDI2LTEwLTI2VDA3OjA1OjAwWioCQkEyAzE3NjoCQkFCAzE3NkgBUgM3NzcSBAgDEAEYASgAMiwKD0JyaXRpc2ggQWlyd2F5cwoIQW1lcmljYW4KBkliZXJpYQoHRmlubmFpcg\\u003d\\u003d\"]",null,0],[["BA",["British Airways"],[[null,null,null,"JFK","John F. Kennedy International Airport","Heathrow Airport","LHR",null,[21,5],1,[8,10],425,[null,null,null,null,null,1,null,null,null,1,null,3],1,"31 in",[["AA","6929",null,"American"],["IB","3544",null,"Iberia"],["AY","5516",null,"Finnair"]],1,"Boeing 777",[1],0,[2026,10,25],[2026,10,26],["BA","116",null,"British Airways"],null,null,1,null,null,null,null,"31 inches",394325,2]],"JFK",[2026,10,25],[21,5],"LHR",[2026,10,26],[8,10],425,1,null,0,null,null,null,["American","Iberia","Finnair"],"exf6kb",[[1789895299889603,16322849,2149534736],null,null,null,null,[[16]]],1,null,null,[null,null,1,-8,null,1,1,394000,430000,null,394000,2,0,null,null,2,null,4],[1],[["BA","British Airways","https://www.britishairways.com/en-gb/information/travel-assistance"]]],[[null,368],"CjRITWg0Y0tvZnpWQW9BSXI1WWdCRy0tLS0tLS0tcGZia3IxNkFBQUFBR3F2b29NTlpRTW1BEgVCQTExNhoLCI6fAhACGgNVU0Q4HXCOnwI\u003d"],null,0,[null,null,null,null,1,null,[null,1]],[0,0,0],0,[],"[\"CAISA1VTRBoECI6fAiKQAQpWClQKA0pGSxIZMjAyNi0xMC0yNVQyMTowNTowMC0wNDowMBoDTEhSIhQyMDI2LTEwLTI2VDA4OjEwOjAwWioCQkEyAzExNjoCQkFCAzExNkgBUgM3N1cSBAgDEAEYASgAMiwKD0JyaXRpc2ggQWlyd2F5cwoIQW1lcmljYW4KBkliZXJpYQoHRmlubmFpcg\\u003d\\u003d\"]",[[1]],0],[["BA",["British Airways"],[[null,null,null,"JFK","John F. Kennedy International Airport","Heathrow Airport","LHR",null,[21,40],1,[8,35],415,[null,null,null,null,null,1,null,null,null,1,null,3],1,"31 in",[["AA","6933",null,"American"],["IB","3558",null,"Iberia"],["AY","5472",null,"Finnair"]],1,"Boeing 777",[1],0,[2026,10,25],[2026,10,26],["BA","172",null,"British Airways"],null,null,1,null,null,null,null,"31 inches",432950,2]],"JFK",[2026,10,25],[21,40],"LHR",[2026,10,26],[8,35],415,1,null,0,null,null,null,["American","Iberia","Finnair"],"mq0jv",[[1789895299889603,16322849,2149534736],null,null,null,null,[[17]]],1,null,null,[null,null,2,1,null,1,1,433000,430000,null,394000,3,0,null,null,2,null,5],[1],[["BA","British Airways","https://www.britishairways.com/en-gb/information/travel-assistance"]]],[[null,368],"CjRITWg0Y0tvZnpWQW9BSXI1WWdCRy0tLS0tLS0tcGZia3IxNkFBQUFBR3F2b29NTlpRTW1BEgVCQTE3MhoLCI6fAhACGgNVU0Q4HXCOnwI\u003d"],null,0,[null,null,null,null,1,null,[null,1]],[0,0,0],0,[],"[\"CAISA1VTRBoECI6fAiKQAQpWClQKA0pGSxIZMjAyNi0xMC0yNVQyMTo0MDowMC0wNDowMBoDTEhSIhQyMDI2LTEwLTI2VDA4OjM1OjAwWioCQkEyAzE3MjoCQkFCAzE3MkgBUgM3NzcSBAgDEAEYASgAMiwKD0JyaXRpc2ggQWlyd2F5cwoIQW1lcmljYW4KBkliZXJpYQoHRmlubmFpcg\\u003d\\u003d\"]",null,0],[["VS",["Virgin Atlantic"],[[null,null,null,"JFK","John F. Kennedy International Airport","Heathrow Airport","LHR",null,[22,10],1,[9,25],435,[null,1,null,null,null,null,null,null,null,1,null,3],1,"31 in",[["AF","6759",null,"Air France"],["DL","5990",null,"Delta"],["KL","2503",null,"KLM"]],1,"Airbus A330-900neo",[1],0,[2026,10,25],[2026,10,26],["VS","10",null,"Virgin Atlantic"],null,null,1,null,null,null,null,"31 inches",385455,2]],"JFK",[2026,10,25],[22,10],"LHR",[2026,10,26],[9,25],435,1,null,0,null,null,null,["Air France","Delta","KLM"],"v90uI",[[1789895299889603,16322849,2149534736],null,null,null,null,[[18]]],1,null,null,[null,null,1,-10,null,1,1,385000,430000,null,394000,2,0,null,null,2,null,4],[1],[["VS","Virgin Atlantic","https://help.virginatlantic.com/gb/en/special-assistance.html"]]],[[null,368],"CjRITWg0Y0tvZnpWQW9BSXI1WWdCRy0tLS0tLS0tcGZia3IxNkFBQUFBR3F2b29NTlpRTW1BEgRWUzEwGgsIjp8CEAIaA1VTRDgdcI6fAg\u003d\u003d"],null,0,[null,null,null,null,1,null,[null,1]],[0,0,0],0,[],"[\"CAISA1VTRBoECI6fAiKLAQpUClIKA0pGSxIZMjAyNi0xMC0yNVQyMjoxMDowMC0wNDowMBoDTEhSIhQyMDI2LTEwLTI2VDA5OjI1OjAwWioCVlMyAjEwOgJWU0ICMTBIAVIDMzM5EgQIAxABGAEoADIpCg9WaXJnaW4gQXRsYW50aWMKCkFpciBGcmFuY2UKBURlbHRhCgNLTE0\\u003d\"]",[[1]],0],[["BA",["British Airways"],[[null,null,null,"JFK","John F. Kennedy International Airport","Heathrow Airport","LHR",null,[22,50],1,[9,45],415,[null,null,null,null,null,1,null,null,null,1,null,3],1,"31 in",[["AA","6914",null,"American"],["IB","3542",null,"Iberia"],["AY","5514",null,"Finnair"]],1,"Boeing 777",[1],0,[2026,10,25],[2026,10,26],["BA","114",null,"British Airways"],null,null,1,null,null,null,null,"31 inches",394325,1]],"JFK",[2026,10,25],[22,50],"LHR",[2026,10,26],[9,45],415,1,null,0,null,null,null,["American","Iberia","Finnair"],"fH0Bfe",[[1789895299889603,16322849,2149534736],null,null,null,null,[[19]]],1,null,null,[null,null,1,-8,null,1,1,394000,430000,null,394000,2,0,null,null,1,null,1],[1],[["BA","British Airways","https://www.britishairways.com/en-gb/information/travel-assistance"]]],[[null,368],"CjRITWg0Y0tvZnpWQW9BSXI1WWdCRy0tLS0tLS0tcGZia3IxNkFBQUFBR3F2b29NTlpRTW1BEgVCQTExNBoLCI6fAhACGgNVU0Q4HXCOnwI\u003d"],null,0,[null,null,null,null,1,null,[null,1]],[0,0,0],0,[],"[\"CAISA1VTRBoECI6fAiKQAQpWClQKA0pGSxIZMjAyNi0xMC0yNVQyMjo1MDowMC0wNDowMBoDTEhSIhQyMDI2LTEwLTI2VDA5OjQ1OjAwWioCQkEyAzExNDoCQkFCAzExNEgBUgM3N1cSBAgDEAEYASgAMiwKD0JyaXRpc2ggQWlyd2F5cwoIQW1lcmljYW4KBkliZXJpYQoHRmlubmFpcg\\u003d\\u003d\"]",[[1]],0],[["VS",["Virgin Atlantic"],[[null,null,null,"JFK","John F. Kennedy International Airport","Heathrow Airport","LHR",null,[20,1],1,[7,15],434,[null,1,null,null,null,null,null,null,null,1,null,3],1,"31 in",[["DL","5992",null,"Delta"],["KL","2507",null,"KLM"]],1,"Airbus A330-900neo",[1],0,[2026,10,25],[2026,10,26],["VS","46",null,"Virgin Atlantic"],null,null,1,null,null,null,null,"31 inches",385455,2]],"JFK",[2026,10,25],[20,1],"LHR",[2026,10,26],[7,15],434,1,null,0,null,null,null,["Delta","KLM"],"EHogNe",[[1789895299889603,16322849,2149534736],null,null,null,null,[[20]]],1,null,null,[null,null,1,-10,null,1,1,385000,430000,null,394000,2,0,null,null,2,null,4],[1],[["VS","Virgin Atlantic","https://help.virginatlantic.com/gb/en/special-assistance.html"]]],[[null,419],"CjRITWg0Y0tvZnpWQW9BSXI1WWdCRy0tLS0tLS0tcGZia3IxNkFBQUFBR3F2b29NTlpRTW1BEgRWUzQ2GgsI+sYCEAIaA1VTRDgdcPrGAg\u003d\u003d"],null,0,[null,null,null,null,1,null,[null,1]],[0,0,0],0,[],"[\"CAISA1VTRBoECPrGAiJ/ClQKUgoDSkZLEhkyMDI2LTEwLTI1VDIwOjAxOjAwLTA0OjAwGgNMSFIiFDIwMjYtMTAtMjZUMDc6MTU6MDBaKgJWUzICNDY6AlZTQgI0NkgBUgMzMzkSBAgDEAEYASgAMh0KD1ZpcmdpbiBBdGxhbnRpYwoFRGVsdGEKA0tMTQ\\u003d\\u003d\"]",[[1]],0],[["VS",["Virgin Atlantic"],[[null,null,null,"JFK","John F. Kennedy International Airport","Heathrow Airport","LHR",null,[19],1,[6,20],440,[null,1,null,null,null,null,null,null,null,1,null,3],1,"31 in",[["AF","6753",null,"Air France"],["DL","5994",null,"Delta"],["KL","2501",null,"KLM"]],1,"Airbus A330-900neo",[1],0,[2026,10,25],[2026,10,26],["VS","4",null,"Virgin Atlantic"],null,null,1,null,null,null,null,"31 inches",385455,2]],"JFK",[2026,10,25],[19],"LHR",[2026,10,26],[6,20],440,1,null,0,null,null,null,["Air France","Delta","KLM"],"WehxL",[[1789895299889603,16322849,2149534736],null,null,null,null,[[21]]],1,null,null,[null,null,1,-10,null,1,1,385000,430000,null,394000,2,0,null,null,2,null,4],[1],[["VS","Virgin Atlantic","https://help.virginatlantic.com/gb/en/special-assistance.html"]]],[[null,444],"CjRITWg0Y0tvZnpWQW9BSXI1WWdCRy0tLS0tLS0tcGZia3IxNkFBQUFBR3F2b29NTlpRTW1BEgNWUzQaCwi+2gIQAhoDVVNEOB1wvtoC"],null,0,[null,null,null,null,1,null,[null,1]],[0,0,0],0,[],"[\"CAISA1VTRBoECL7aAiKJAQpSClAKA0pGSxIZMjAyNi0xMC0yNVQxOTowMDowMC0wNDowMBoDTEhSIhQyMDI2LTEwLTI2VDA2OjIwOjAwWioCVlMyATQ6AlZTQgE0SAFSAzMzORIECAMQARgBKAAyKQoPVmlyZ2luIEF0bGFudGljCgpBaXIgRnJhbmNlCgVEZWx0YQoDS0xN\"]",[[1]],0]],0,0,0,[1]],null,[4,[null,295],[null,295],[null,-1],[null,280],[null,295],1,null,null,null,[[[1784606400000,285],[1784692800000,285],[1784779200000,285],[1784865600000,285],[1784952000000,285],[1785038400000,285],[1785124800000,285],[1785211200000,285],[1785297600000,285],[1785384000000,285],[1785470400000,295],[1785556800000,295],[1785643200000,295],[1785729600000,295],[1785816000000,295],[1785902400000,295],[1785988800000,295],[1786075200000,295],[1786161600000,295],[1786248000000,295],[1786334400000,295],[1786420800000,295],[1786507200000,295],[1786593600000,295],[1786680000000,295],[1786766400000,295],[1786852800000,295],[1786939200000,295],[1787025600000,295],[1787112000000,295],[1787198400000,295],[1787284800000,295],[1787371200000,295],[1787457600000,295],[1787544000000,295],[1787630400000,295],[1787716800000,295],[1787803200000,295],[1787889600000,295],[1787976000000,295],[1788062400000,295],[1788148800000,295],[1788235200000,295],[1788321600000,295],[1788408000000,295],[1788494400000,295],[1788580800000,295],[1788667200000,295],[1788753600000,295],[1788840000000,295],[1788926400000,295],[1789012800000,295],[1789099200000,295],[1789185600000,295],[1789272000000,295],[1789358400000,295],[1789444800000,295],[1789531200000,295],[1789617600000,295],[1789704000000,295],[1789790400000,295],[1789876800000,295]]],[[1789895299889603,16322849,2149534736],null,null,null,null,[[22]]],"London"],null,[[[null,291],[null,2617]],[[["ONEWORLD","Oneworld"],["SKYTEAM","SkyTeam"],["STAR_ALLIANCE","Star Alliance"]],[["EI","Aer Lingus"],["AF","Air France"],["JU","Air Serbia"],["AS","Alaska"],["AA","American"],["OS","Austrian"],["S4","Azores Airlines"],["BA","British Airways"],["SN","Brussels Airlines"],["DE","Condor"],["DL","Delta"],["AY","Finnair"],["GF","Gulf Air"],["IB","Iberia"],["FI","Icelandair"],["6E","IndiGo"],["AZ","ITA"],["B6","JetBlue"],["KL","KLM"],["LO","LOT"],["LH","Lufthansa"],["MH","Malaysia Airlines"],["PK","Pakistan International Airlines"],["QR","Qatar Airways"],["AT","Royal Air Maroc"],["SV","Saudia"],["SK","Scandinavian Airlines"],["SQ","Singapore Airlines"],["LX","SWISS"],["TP","Tap Air Portugal"],["TG","THAI"],["TK","Turkish Airlines"],["UA","United"],["VS","Virgin Atlantic"],["WS","WestJet"]]],[[["AMS","Amsterdam"],["ATL","Atlanta"],["BCN","Barcelona"],["BOS","Boston"],["BRU","Brussels"],["CMN","Casablanca"],["CLT","Charlotte"],["ORD","Chicago"],["CVG","Cincinnati"],["CPH","Copenhagen"],["DTW","Detroit"],["DUB","Dublin"],["FRA","Frankfurt am Main"],["GVA","Geneva"],["HEL","Helsinki"],["LIS","Lisbon"],["MAD","Madrid"],["MIA","Miami"],["MXP","Milan"],["MSP","Minneapolis"],["MUC","Munich"],["CDG","Paris"],["RDU","Raleigh"],["KEF","Reykjavík"],["FCO","Rome"],["SNN","Shannon"],["WAW","Warsaw"],["IAD","Washington"],["ZRH","Zürich"]],40,835],[410,1295],[[1,2,3]],[1,0,0,0],null,[0]],null,null,null,[["AA","American","https://www.aa.com/i18n/travel-info/baggage/checked-baggage-policy.jsp"],["BA","British Airways","http://www.britishairways.com/travel/bagchk/public/en_gb"],["DL","Delta","https://www.delta.com/content/www/en_US/traveling-with-us/baggage/before-your-trip/checked.html"],["B6","JetBlue","https://www.jetblue.com/at-the-airport/baggage-information?intcmp\u003dhd_info"],["VS","Virgin Atlantic","https://www.virginatlantic.com/en-US/help/categories/070fb328-0c1c-4a04-a2bf-795834008bf1"]],["EAEaBAgDEAEhAAAAAABockAqA1VTRDIaChgKA0pGSxIDTEhSGgoyMDI2LTEwLTI1IABQAWIvCh4KBwoDSkZLEAESBwoDTEhSEAEaCjIwMjYtMTAtMjUaDQoECAMQARABGACIAQFoAHC37eAycJHd1jJwx9DfMg\u003d\u003d",0],null,[[1789895299889603,16322849,2149534736],null,null,null,null,[[0]]],null,null,[[["AMS",0],"Amsterdam Airport Schiphol",["/m/0k3p","Amsterdam",[["https://encrypted-tbn1.gstatic.com/images?q\u003dtbn:ANd9GcRiH-EGCc5jbyYbopiqf-g80xO0O5pxPnlJESLyIsY2uvo-gB84S94Q4C9kNWoKQ_eQ3OU-6evapBnb7TquB4zg3p3fQEGA3wpbxxhRdx0"],["https://encrypted-tbn1.gstatic.com/images?q\u003dtbn:ANd9GcRTHETZVxU4_OrKq24sf7n7HS_0ca3__1_Urs251dzMXLn16tZy8J8x5i1phGimLkrbGL2gDKGrA-U35g"]]],[52.3080556,4.76416667],"NL",0,"Netherlands"],[["/m/0k3p",4],"Amsterdam",["/m/0k3p","Amsterdam",[["https://encrypted-tbn1.gstatic.com/images?q\u003dtbn:ANd9GcRiH-EGCc5jbyYbopiqf-g80xO0O5pxPnlJESLyIsY2uvo-gB84S94Q4C9kNWoKQ_eQ3OU-6evapBnb7TquB4zg3p3fQEGA3wpbxxhRdx0"],["https://encrypted-tbn1.gstatic.com/images?q\u003dtbn:ANd9GcRTHETZVxU4_OrKq24sf7n7HS_0ca3__1_Urs251dzMXLn16tZy8J8x5i1phGimLkrbGL2gDKGrA-U35g"]],"Cycling, canals \u0026 the Van Gogh Museum","Netherlands capital, with canals, cycle paths \u0026 museums with works by Van Gogh, Rembrandt \u0026 Vermeer.","AMS"],[52.3675734,4.9041389],"NL",null,"Netherlands"],[["ATL",0],"Hartsfield-Jackson Atlanta International Airport",["/m/013yq","Atlanta",[["https://encrypted-tbn3.gstatic.com/images?q\u003dtbn:ANd9GcRJh6WEANkd6cril2a8Csnk2i_WTs-ZTUE-pamQ4iTfpTi0hlx5P9xhDKrUeBWRPb-4hiLgvoegdgPZ2t2R8qpkN_a7BzJjUNSnSonV664"],["https://encrypted-tbn3.gstatic.com/images?q\u003dtbn:ANd9GcQYBXd-jsaFCOrq3Ftbagud_RXYRp8gK_jeDmxAfPmI5pP7SIRedYhExpUTLErX68PeHFvOzs8P_D0v_w"]]],[33.6366667,-84.427778],"US",0,"United States"],[["/m/013yq",4],"Atlanta",["/m/013yq","Atlanta",[["https://encrypted-tbn3.gstatic.com/images?q\u003dtbn:ANd9GcRJh6WEANkd6cril2a8Csnk2i_WTs-ZTUE-pamQ4iTfpTi0hlx5P9xhDKrUeBWRPb-4hiLgvoegdgPZ2t2R8qpkN_a7BzJjUNSnSonV664"],["https://encrypted-tbn3.gstatic.com/images?q\u003dtbn:ANd9GcQYBXd-jsaFCOrq3Ftbagud_RXYRp8gK_jeDmxAfPmI5pP7SIRedYhExpUTLErX68PeHFvOzs8P_D0v_w"]],"Coca-Cola, Buckhead \u0026 Martin Luther King","Georgia capital with Coca-Cola museum, Buckhead \u0026 Martin Luther King Jr National Historic Site.","ATL"],[33.7501275,-84.3885209],"US",null,"United States"],[["BCN",0],"Josep Tarradellas Barcelona-El Prat Airport",["/m/01f62","Barcelona",[["https://encrypted-tbn0.gstatic.com/images?q\u003dtbn:ANd9GcSm8RLrNH5mwpZ7VV_y8imJgifZndKGVUDYaU5-3_hF41Qrpet1SbU1az4wU48pwjNcbuAC9cYwCNqDCxMF1MgcMCvzO0P__9pb0Q9JBGM"],["https://encrypted-tbn0.gstatic.com/images?q\u003dtbn:ANd9GcQOk3xypjQxrqfZPlTUH5lubWcGBzOkdXv7IVkOL--w1FYohepC2Y1hN69JZMcmQsAOt2hIy7EWP0SfXA"]]],[41.2969444,2.07833333],"ES",0,"Spain"],[["/m/01f62",4],"Barcelona",["/m/01f62","Barcelona",[["https://encrypted-tbn0.gstatic.com/images?q\u003dtbn:ANd9GcSm8RLrNH5mwpZ7VV_y8imJgifZndKGVUDYaU5-3_hF41Qrpet1SbU1az4wU48pwjNcbuAC9cYwCNqDCxMF1MgcMCvzO0P__9pb0Q9JBGM"],["https://encrypted-tbn0.gstatic.com/images?q\u003dtbn:ANd9GcQOk3xypjQxrqfZPlTUH5lubWcGBzOkdXv7IVkOL--w1FYohepC2Y1hN69JZMcmQsAOt2hIy7EWP0SfXA"]],"Gaudí buildings, Gothic Quarter \u0026 tapas","Catalan capital known for Gaudí’s whimsical architecture, the Gothic Quarter \u0026 tapas bars.","BCN"],[41.3874374,2.1686496],"ES",null,"Spain"],[["BOS",0],"Boston Logan International Airport",["/m/01cx_","Boston",[["https://encrypted-tbn3.gstatic.com/images?q\u003dtbn:ANd9GcTmyfqYldUKPJdrEh9tMEkjc-XwVb6VUgvvAhx1n4EUeXRSkCPp1-NQAofPisLnWMTcastf8G7m1fVavxIZ4tviHRyoXXRpqKgvkC8ja3w"],["https://encrypted-tbn3.gstatic.com/images?q\u003dtbn:ANd9GcTsThI_7VKLWvxDOugOLpVHze3RQP7rvr-KLjOZJ0PEf2xI8bEhumBB3ZjXe4HF-8srxAhSOe22Cjuc1g"]]],[42.3630556,-71.006389],"US",0,"United States"],[["/m/01cx_",4],"Boston",["/m/01cx_","Boston",[["https://encrypted-tbn3.gstatic.com/images?q\u003dtbn:ANd9GcTmyfqYldUKPJdrEh9tMEkjc-XwVb6VUgvvAhx1n4EUeXRSkCPp1-NQAofPisLnWMTcastf8G7m1fVavxIZ4tviHRyoXXRpqKgvkC8ja3w"],["https://encrypted-tbn3.gstatic.com/images?q\u003dtbn:ANd9GcTsThI_7VKLWvxDOugOLpVHze3RQP7rvr-KLjOZJ0PEf2xI8bEhumBB3ZjXe4HF-8srxAhSOe22Cjuc1g"]],"Freedom Trail, Red Sox \u0026 clam chowder","Massachusetts capital known for Revolutionary War history, Red Sox baseball \u0026 clam chowder.","BOS"],[42.3555076,-71.0565364],"US",null,"United States"],[["BRU",0],"Brussels Airport",["/m/0177z","Brussels",[["https://encrypted-tbn3.gstatic.com/images?q\u003dtbn:ANd9GcStyvM0Dr4uahvFMpUNUFdZonsFbnG1iOfrOE18sIzXDZfDJ-sW1GLxKAWBSbN4_JXwti4rmD51AVJbBozlWRCfRGjDuVwv3QSHVwUH7I4"],["https://encrypted-tbn3.gstatic.com/images?q\u003dtbn:ANd9GcRIn7vzriQPtnqUpMwNMNZsZkbkPp6ulyZFG8ueQMxK8owxSxT-_ibT7ou7CgKbMpw_VaK6YyyGbp1kfw"]]],[50.9013889,4.48444444],"BE",0,"Belgium"],[["/m/0177z",4],"Brussels",["/m/0177z","Brussels",[["https://encrypted-tbn3.gstatic.com/images?q\u003dtbn:ANd9GcStyvM0Dr4uahvFMpUNUFdZonsFbnG1iOfrOE18sIzXDZfDJ-sW1GLxKAWBSbN4_JXwti4rmD51AVJbBozlWRCfRGjDuVwv3QSHVwUH7I4"],["https://encrypted-tbn3.gstatic.com/images?q\u003dtbn:ANd9GcRIn7vzriQPtnqUpMwNMNZsZkbkPp6ulyZFG8ueQMxK8owxSxT-_ibT7ou7CgKbMpw_VaK6YyyGbp1kfw"]],"Belgian capital \u0026 headquarters of the EU","Belgian capital \u0026 European Union headquarters, known for its Grand-Place \u0026 comic-strip murals.","BRU"],[50.8260453,4.3802052],"BE",null,"Belgium"],[["CDG",0],"Aéroport de Paris-Charles de Gaulle",["/m/05qtj","Paris",[["https://encrypted-tbn3.gstatic.com/images?q\u003dtbn:ANd9GcSyQJ-woNs0iO22mPSkmRUM5gcsTbbYeypQ6BBTeFxXr90mqTxZl57Fdq2CDuLn4w7cKZ8TT9_zZhOpF57rIpA7yWKQnqKvkKIf9Y-qJDo"],["https://encrypted-tbn3.gstatic.com/images?q\u003dtbn:ANd9GcQGx8ii2KbSDdbdzfKye5oDN2bwBA6audqI7XUEf2iMRZezpn_ZbQe1ZIuvUSH-8XOMe958umDwSsAF1w"]]],[49.0097222,2.54777778],"FR",0,"France"],[["/m/05qtj",4],"Paris",["/m/05qtj","Paris",[["https://encrypted-tbn3.gstatic.com/images?q\u003dtbn:ANd9GcSyQJ-woNs0iO22mPSkmRUM5gcsTbbYeypQ6BBTeFxXr90mqTxZl57Fdq2CDuLn4w7cKZ8TT9_zZhOpF57rIpA7yWKQnqKvkKIf9Y-qJDo"],["https://encrypted-tbn3.gstatic.com/images?q\u003dtbn:ANd9GcQGx8ii2KbSDdbdzfKye5oDN2bwBA6audqI7XUEf2iMRZezpn_ZbQe1ZIuvUSH-8XOMe958umDwSsAF1w"]],"Eiffel Tower, Louvre, cafes \u0026 fashion","France's capital, home to the Eiffel Tower, Louvre, Notre-Dame, sidewalk cafes \u0026 high fashion.","PAR"],[48.8575475,2.3513765],"FR",null,"France"],[["CHI",0],"Metropolitan Area",["/m/01_d4","Chicago",[["https://encrypted-tbn2.gstatic.com/images?q\u003dtbn:ANd9GcR0CK6-eZWtnTJdtBk0BnPl1NeBcRul1YiurNp0AEgxFjNRleXR3vb2VV6vc5Uk51C0AhYN6AZAQKz6FJ-NQfbjVf8HQQ96ZH3WYIS-Rw0"],["https://encrypted-tbn2.gstatic.com/images?q\u003dtbn:ANd9GcTDuw95ynLqGCkZRzt9XuWXGBs8qWhw_1UZkMrCRAQp3rojEZBpwitHM8GAMBXgKhSKFgJZcXZ3qmYs2g"]]],[41.8781136,-87.6297982],"US",0,"United States"],[["/m/01_d4",4],"Chicago",["/m/01_d4","Chicago",[["https://encrypted-tbn2.gstatic.com/images?q\u003dtbn:ANd9GcR0CK6-eZWtnTJdtBk0BnPl1NeBcRul1YiurNp0AEgxFjNRleXR3vb2VV6vc5Uk51C0AhYN6AZAQKz6FJ-NQfbjVf8HQQ96ZH3WYIS-Rw0"],["https://encrypted-tbn2.gstatic.com/images?q\u003dtbn:ANd9GcTDuw95ynLqGCkZRzt9XuWXGBs8qWhw_1UZkMrCRAQp3rojEZBpwitHM8GAMBXgKhSKFgJZcXZ3qmYs2g"]],"Willis Tower, the Cubs \u0026 deep-dish pizza","Lakeside Illinois city known for the Willis Tower, Cubs baseball at Wrigley Field \u0026 deep-dish pizza.","CHI"],[41.88325,-87.6323879],"US",null,"United States"],[["CLT",0],"Charlotte Douglas International Airport",["/m/0fsb8","Charlotte",[["https://encrypted-tbn0.gstatic.com/images?q\u003dtbn:ANd9GcQBchVV4pdmzP11cPnwAoD4KOct7bDtjJNWSFB2L1fGz-MTVbc4nonWQLTb5CBBOC74uf2VWBJDSwjGDxZ-T5urLRlK2yFa_LfRvefLZE8"],["https://encrypted-tbn0.gstatic.com/images?q\u003dtbn:ANd9GcRWAK9fbD721wm19k-k3weRKlIpwTRi-8HLppddgJHMD0RLMnysMN_bpvyqhuac14kaTD0Y1nizGmFF2Q"]]],[35.2136111,-80.949167],"US",0,"United States"],[["/m/0fsb8",4],"Charlotte",["/m/0fsb8","Charlotte",[["https://encrypted-tbn0.gstatic.com/images?q\u003dtbn:ANd9GcQBchVV4pdmzP11cPnwAoD4KOct7bDtjJNWSFB2L1fGz-MTVbc4nonWQLTb5CBBOC74uf2VWBJDSwjGDxZ-T5urLRlK2yFa_LfRvefLZE8"],["https://encrypted-tbn0.gstatic.com/images?q\u003dtbn:ANd9GcRWAK9fbD721wm19k-k3weRKlIpwTRi-8HLppddgJHMD0RLMnysMN_bpvyqhuac14kaTD0Y1nizGmFF2Q"]],"NASCAR, Southern history \u0026 art museums","North Carolina city offering the NASCAR Hall of Fame, Levine Museum of the New South \u0026 art museums.","CLT"],[35.2270768,-80.8408933],"US",null,"United States"],[["CMN",0],"Casablanca Mohammed V International Airport",["/m/022b_","Casablanca",[["https://encrypted-tbn2.gstatic.com/images?q\u003dtbn:ANd9GcT5OAwW5K0ThVCnmR0G9JcPfDwzidBzSFvRU2EIXCCCK5IHpYDCzVuCNsFVw8ayiniU0vyJTaZJUePC-iItAJ70gU9saNxGP6Xj84wQt1Q"],["https://encrypted-tbn2.gstatic.com/images?q\u003dtbn:ANd9GcSqTf5tE7Q5QBtAT00PHJvD2zRcuykr6iD0rJhJfIOZZoNIYZABQRJ7ccpmLehWthx_adFjzDBYXVgo9A"]]],[33.3641667,-7.5816667],"MA",0,"Morocco"],[["/m/022b_",4],"Casablanca",["/m/022b_","Casablanca",[["https://encrypted-tbn2.gstatic.com/images?q\u003dtbn:ANd9GcT5OAwW5K0ThVCnmR0G9JcPfDwzidBzSFvRU2EIXCCCK5IHpYDCzVuCNsFVw8ayiniU0vyJTaZJUePC-iItAJ70gU9saNxGP6Xj84wQt1Q"],["https://encrypted-tbn2.gstatic.com/images?q\u003dtbn:ANd9GcSqTf5tE7Q5QBtAT00PHJvD2zRcuykr6iD0rJhJfIOZZoNIYZABQRJ7ccpmLehWthx_adFjzDBYXVgo9A"]],"Mauresque buildings \u0026 Hassan II Mosque","Moroccan port city with Moorish–art decol Mauresque architecture \u0026 the waterfront Hassan II Mosque.","CMN"],[33.5731104,-7.5898434],"MA",null,"Morocco"],[["CPH",0],"Copenhagen Airport",["/m/01lfy","Copenhagen",[["https://encrypted-tbn3.gstatic.com/images?q\u003dtbn:ANd9GcRR3iKAPizSfqvzbasJAysStzVm-vU6d4F9Fmf19f2GVsiqO9uY38FgTxqJh_U6ZJyIuVXzHaM-Y1RszLUufA43Md0I5Fscr176mL7mro8"],["https://encrypted-tbn3.gstatic.com/images?q\u003dtbn:ANd9GcTMeTpQ6hOphBsGySbGGhoKcS8Kj8O3OCEm_Mk0zB4C5nKyHtROn2em-pOm8twY3ufSMC987_mUhGls_w"]]],[55.6180556,12.6561111],"DK",0,"Denmark"],[["/m/01lfy",4],"Copenhagen",["/m/01lfy","Copenhagen",[["https://encrypted-tbn3.gstatic.com/images?q\u003dtbn:ANd9GcRR3iKAPizSfqvzbasJAysStzVm-vU6d4F9Fmf19f2GVsiqO9uY38FgTxqJh_U6ZJyIuVXzHaM-Y1RszLUufA43Md0I5Fscr176mL7mro8"],["https://encrypted-tbn3.gstatic.com/images?q\u003dtbn:ANd9GcTMeTpQ6hOphBsGySbGGhoKcS8Kj8O3OCEm_Mk0zB4C5nKyHtROn2em-pOm8twY3ufSMC987_mUhGls_w"]],"Tivoli, palaces \u0026 \"The Little Mermaid\"","Denmark’s capital with Tivoli amusement park, royal palaces \u0026 iconic statue of “The Little Mermaid.\"","CPH"],[55.6760968,12.5683371],"DK",null,"Denmark"],[["CVG",0],"Cincinnati/Northern Kentucky International Airport",["/m/01snm","Cincinnati",[["https://encrypted-tbn1.gstatic.com/images?q\u003dtbn:ANd9GcSSKCH_kANwGq7C2YOvc-p50vfS6I8u3NZOBRe1YOmTddTp2VbZU2EZWirfoGOpqlRXuelvO-YBbIhH-8CjKwyX9Y7aTK50NoOX5i7EivE"],["https://encrypted-tbn1.gstatic.com/images?q\u003dtbn:ANd9GcSycOxCntztnubfIWXDBT1iKNxy5S_jO9UAcDIWqQniNV2n1wxSZsSq-diqbFuL9hfNTjnduJP1P66-9w"]]],[39.0488889,-84.667778],"US",0,"United States"],[["/m/01snm",4],"Cincinnati",["/m/01snm","Cincinnati",[["https://encrypted-tbn1.gstatic.com/images?q\u003dtbn:ANd9GcSSKCH_kANwGq7C2YOvc-p50vfS6I8u3NZOBRe1YOmTddTp2VbZU2EZWirfoGOpqlRXuelvO-YBbIhH-8CjKwyX9Y7aTK50NoOX5i7EivE"],["https://encrypted-tbn1.gstatic.com/images?q\u003dtbn:ANd9GcSycOxCntztnubfIWXDBT1iKNxy5S_jO9UAcDIWqQniNV2n1wxSZsSq-diqbFuL9hfNTjnduJP1P66-9w"]],"Cincinnati Museum Center \u0026 zoo","Ohio city with Cincinnati Museum Center, Cincinnati Zoo \u0026 Over-the-Rhine district architecture.","CVG"],[39.1031182,-84.5120196],"US",null,"United States"],[["DTW",0],"Detroit Metropolitan Wayne County Airport",["/m/02dtg","Detroit",[["https://encrypted-tbn3.gstatic.com/images?q\u003dtbn:ANd9GcSLzktjJPbJWpjXl1ZSYRz56GZ46-c_yoPIjxNBooT6XhL3kRcO9Hgj4d61TOWWofyftp77t-Xphkog3mdEoWczq1_BbvKctQL77uK5nC0"],["https://encrypted-tbn3.gstatic.com/images?q\u003dtbn:ANd9GcQ6tCKi37Y2EFKBit2BFOdzMPDMIOPD61N33bJ6TPBfGhdv-qnbRdXODK9GFZ4072j7q-CnrkO_vQFBTQ"]]],[42.2125,-83.353333],"US",0,"United States"],[["/m/02dtg",4],"Detroit",["/m/02dtg","Detroit",[["https://encrypted-tbn3.gstatic.com/images?q\u003dtbn:ANd9GcSLzktjJPbJWpjXl1ZSYRz56GZ46-c_yoPIjxNBooT6XhL3kRcO9Hgj4d61TOWWofyftp77t-Xphkog3mdEoWczq1_BbvKctQL77uK5nC0"],["https://encrypted-tbn3.gstatic.com/images?q\u003dtbn:ANd9GcQ6tCKi37Y2EFKBit2BFOdzMPDMIOPD61N33bJ6TPBfGhdv-qnbRdXODK9GFZ4072j7q-CnrkO_vQFBTQ"]],"Michigan city famed for cars \u0026 Motown","Michigan city known for its auto industry, Detroit Institute of Art \u0026 as the birthplace of Motown.","DTT"],[42.3297182,-83.0424533],"US",null,"United States"],[["DUB",0],"Dublin Airport",["/m/02cft","Dublin",[["https://encrypted-tbn3.gstatic.com/images?q\u003dtbn:ANd9GcTIjbp7MhaueMFQPbe7J2njYObGlapS7hfuaJap2rN3YTbJVCV9iA3ijgoNg6bZjvhOWIYgIBWSrnd_QkrpwmQW6JdOWQ0BaUm_qrplGXo"],["https://encrypted-tbn3.gstatic.com/images?q\u003dtbn:ANd9GcQpZqyX2kbFJR9GduoH6ML3JqVg2HdmGthLLdTt5wc1kNgWbP-kUpV4VhucbjQXr01K0BaIPQgEoPvwEQ"]]],[53.4213889,-6.27],"IE",0,"Ireland"],[["/m/02cft",4],"Dublin",["/m/02cft","Dublin",[["https://encrypted-tbn3.gstatic.com/images?q\u003dtbn:ANd9GcTIjbp7MhaueMFQPbe7J2njYObGlapS7hfuaJap2rN3YTbJVCV9iA3ijgoNg6bZjvhOWIYgIBWSrnd_QkrpwmQW6JdOWQ0BaUm_qrplGXo"],["https://encrypted-tbn3.gstatic.com/images?q\u003dtbn:ANd9GcQpZqyX2kbFJR9GduoH6ML3JqVg2HdmGthLLdTt5wc1kNgWbP-kUpV4VhucbjQXr01K0BaIPQgEoPvwEQ"]],"A castle, museums \u0026 the Book of Kells","The Republic of Ireland's capital, home to the Book of Kells, Dublin Castle \u0026 numerous museums.","DUB"],[53.3498053,-6.2603097],"IE",null,"Ireland"],[["FCO",0],"Leonardo da Vinci International Airport",["/m/06c62","Rome",[["https://encrypted-tbn1.gstatic.com/images?q\u003dtbn:ANd9GcRM_5snkSVZsnpG8dhW0NGx_Pdwk592nbBjmyqu-UxZDclvuBr6HXfXd0Fm7TYGVQpVCCr4RC6TGTmOgyP6KwpvZr0tGGnpZ7ukzP8RPLA"],["https://encrypted-tbn1.gstatic.com/images?q\u003dtbn:ANd9GcT2IU9ZUmvhvThfVJdnmh0sazh2RYI04-GSv0_GLCW7m3TnPpi1XYRNkIuXyL-bdJRgPn7Akcbg6zmDzw"]]],[41.8002778,12.2388889],"IT",0,"Italy"],[["/m/06c62",4],"Rome",["/m/06c62","Rome",[["https://encrypted-tbn1.gstatic.com/images?q\u003dtbn:ANd9GcRM_5snkSVZsnpG8dhW0NGx_Pdwk592nbBjmyqu-UxZDclvuBr6HXfXd0Fm7TYGVQpVCCr4RC6TGTmOgyP6KwpvZr0tGGnpZ7ukzP8RPLA"],["https://encrypted-tbn1.gstatic.com/images?q\u003dtbn:ANd9GcT2IU9ZUmvhvThfVJdnmh0sazh2RYI04-GSv0_GLCW7m3TnPpi1XYRNkIuXyL-bdJRgPn7Akcbg6zmDzw"]],"The Colosseum, iconic art \u0026 the Vatican","Italy's capital, home to the Vatican as well as world-class art \u0026 ancient ruins like the Colosseum.","ROM"],[41.8967068,12.4822025],"IT",null,"Italy"],[["FRA",0],"Frankfurt Airport",["/m/02z0j","Frankfurt am Main",[["https://encrypted-tbn3.gstatic.com/images?q\u003dtbn:ANd9GcRthwXcj3pIl7-x_4xgko5YQeqkTISsGgqS8vvDyYGQIu3lfxXz40TSEiN_5YR7AfORo7EaBO1V46ilVJueQaqWGBb5GzrVbbIt2vBOALM"],["https://encrypted-tbn3.gstatic.com/images?q\u003dtbn:ANd9GcRqdKUfBWQXvmp7-Y6p2lZnjO0xPPGMl7Wnh1tOp4QR5QfoOyaq2AqdvByEgXmwe_eGAYewCKeUlXGxqQ"]]],[50.0333333,8.575],"DE",0,"Germany"],[["/m/02z0j",4],"Frankfurt am Main",["/m/02z0j","Frankfurt am Main",[["https://encrypted-tbn3.gstatic.com/images?q\u003dtbn:ANd9GcRthwXcj3pIl7-x_4xgko5YQeqkTISsGgqS8vvDyYGQIu3lfxXz40TSEiN_5YR7AfORo7EaBO1V46ilVJueQaqWGBb5GzrVbbIt2vBOALM"],["https://encrypted-tbn3.gstatic.com/images?q\u003dtbn:ANd9GcRqdKUfBWQXvmp7-Y6p2lZnjO0xPPGMl7Wnh1tOp4QR5QfoOyaq2AqdvByEgXmwe_eGAYewCKeUlXGxqQ"]],"Banking, Goethe House \u0026 museums","German riverside city with European Central Bank, plus Goethe House, Städel \u0026 other notable museums.","FRA"],[50.1109221,8.6821267],"DE",null,"Germany"],[["GVA",0],"Geneva Airport",["/m/03902","Geneva",[["https://encrypted-tbn1.gstatic.com/images?q\u003dtbn:ANd9GcQmN8-AOBQ6QXGfk26E8voligyWqzvldc8Cx5n9RcEnIC8WE1p-i9s379ThASMlgVpXAiNHIH7owjnFAtV1HSgwqxHvCAijt8MBahDsWRs"],["https://encrypted-tbn1.gstatic.com/images?q\u003dtbn:ANd9GcRgx03CYHtPmXwLBBNkpK46NZNFpo0abz2FkXT5FhaXoGQRaSF8ye8xTvvwNh7caWVT8GZyH1FjvQ4idA"]]],[46.2380556,6.10888889],"CH",0,"Switzerland"],[["/m/03902",4],"Geneva",["/m/03902","Geneva",[["https://encrypted-tbn1.gstatic.com/images?q\u003dtbn:ANd9GcQmN8-AOBQ6QXGfk26E8voligyWqzvldc8Cx5n9RcEnIC8WE1p-i9s379ThASMlgVpXAiNHIH7owjnFAtV1HSgwqxHvCAijt8MBahDsWRs"],["https://encrypted-tbn1.gstatic.com/images?q\u003dtbn:ANd9GcRgx03CYHtPmXwLBBNkpK46NZNFpo0abz2FkXT5FhaXoGQRaSF8ye8xTvvwNh7caWVT8GZyH1FjvQ4idA"]],"Lake Geneva, Old Town \u0026 United Nations","Swiss city on Lake Geneva with United Nations headquarters, a cobbled Old Town \u0026 art museums.","GVA"],[46.2043907,6.1431577],"CH",null,"Switzerland"],[["HEL",0],"Helsinki Airport",["/m/03khn","Helsinki",[["https://encrypted-tbn0.gstatic.com/images?q\u003dtbn:ANd9GcRIuW5WgVjD2DLfglhlGhmaPXv6vbFWDXtT7bV0rLq50lOR-ufQ0Fojd_Sd5xud7KTMHldsgxlJqLNyiN74A_HnBKSm1nbfpCeXN04RCsI"],["https://encrypted-tbn0.gstatic.com/images?q\u003dtbn:ANd9GcS05kTtTqSlcsoKJL9WW_52u7gLgMRutIuCrOUmZqI-DAdWvfve-Bw9F57t6UbjnTkbdUKnnimkHebexw"]]],[60.3166667,24.9572222],"FI",0,"Finland"],[["/m/03khn",4],"Helsinki",["/m/03khn","Helsinki",[["https://encrypted-tbn0.gstatic.com/images?q\u003dtbn:ANd9GcRIuW5WgVjD2DLfglhlGhmaPXv6vbFWDXtT7bV0rLq50lOR-ufQ0Fojd_Sd5xud7KTMHldsgxlJqLNyiN74A_HnBKSm1nbfpCeXN04RCsI"],["https://encrypted-tbn0.gstatic.com/images?q\u003dtbn:ANd9GcS05kTtTqSlcsoKJL9WW_52u7gLgMRutIuCrOUmZqI-DAdWvfve-Bw9F57t6UbjnTkbdUKnnimkHebexw"]],"Suomenlinna sea fort, museums \u0026 shops","Finnish capital known for its neoclassical cathedral, Design District shops \u0026 Suomenlinna sea fort.","HEL"],[60.1698557,24.938379],"FI",null,"Finland"],[["IAD",0],"Dulles International Airport",["/m/0rh6k","Washington",[["https://encrypted-tbn1.gstatic.com/images?q\u003dtbn:ANd9GcRMLLOliMVP16YVOyMBlzc0Gmxx-R5fU2bSGBN2tw9x-6tWr0q5I3bRnaMOot3V_SMDxjwVNjxd3aIlFxHtZL0Yc8rVnZAQAs2upGkhIZ0"],["https://encrypted-tbn1.gstatic.com/images?q\u003dtbn:ANd9GcRG0OK4wTkRsqDVobvhtBOPZMDsUETpgJ7jPzOA--4D-HL-0BVkyp4S9gvw7CBWMKyfFVS0lLRn7pmR-Q"]]],[38.9475,-77.46],"US",0,"United States"],[["/m/0rh6k",4],"Washington, D.C.",["/m/0rh6k","Washington, D.C.",[["https://encrypted-tbn1.gstatic.com/images?q\u003dtbn:ANd9GcRMLLOliMVP16YVOyMBlzc0Gmxx-R5fU2bSGBN2tw9x-6tWr0q5I3bRnaMOot3V_SMDxjwVNjxd3aIlFxHtZL0Yc8rVnZAQAs2upGkhIZ0"],["https://encrypted-tbn1.gstatic.com/images?q\u003dtbn:ANd9GcRG0OK4wTkRsqDVobvhtBOPZMDsUETpgJ7jPzOA--4D-HL-0BVkyp4S9gvw7CBWMKyfFVS0lLRn7pmR-Q"]],"U.S. capital \u0026 home to the Smithsonian","The U.S. Capital, home to the federal government \u0026 cultural institutions such as the Smithsonian.","WAS"],[38.9072873,-77.0369274],"US",null,"United States"],[["JFK",0],"John F. Kennedy International Airport",["/m/02_286","New York",[["https://encrypted-tbn1.gstatic.com/images?q\u003dtbn:ANd9GcQEaUa9NsdPWGpAUGkTApkZDT_4M6_6V8wTcC0v1b1wJAJX-BuMSiipXbsoznGgcI1xLOc5QiTcR_xovexgjdOz0gqQe0tRQ9h0bUkZ07Q"],["https://encrypted-tbn1.gstatic.com/images?q\u003dtbn:ANd9GcRa1dwH1NZQk4dsbPiyA9Vrq2RX75jXSZ-OkHn7NkLHl-11HercqDXoZ4p2cDxJkH6vca2degawrCzHEQ"]]],[40.6397222,-73.778889],"US",0,"United States"],[["/m/02_286",4],"New York",["/m/02_286","New York",[["https://encrypted-tbn1.gstatic.com/images?q\u003dtbn:ANd9GcQEaUa9NsdPWGpAUGkTApkZDT_4M6_6V8wTcC0v1b1wJAJX-BuMSiipXbsoznGgcI1xLOc5QiTcR_xovexgjdOz0gqQe0tRQ9h0bUkZ07Q"],["https://encrypted-tbn1.gstatic.com/images?q\u003dtbn:ANd9GcRa1dwH1NZQk4dsbPiyA9Vrq2RX75jXSZ-OkHn7NkLHl-11HercqDXoZ4p2cDxJkH6vca2degawrCzHEQ"]],"Statue of Liberty, skyscrapers \u0026 culture","Influential metropolis known for the Statue of Liberty, Empire State Building \u0026 Times Square.","NYC"],[40.7127753,-74.0059728],"US",null,"United States"],[["KEF",0],"Keflavík International Airport",["/m/06flg","Reykjavík",[["https://encrypted-tbn1.gstatic.com/images?q\u003dtbn:ANd9GcRlJC6KzgAknt5cecen-bV6fKYMBcNcPLXmKLOXq02cjaWenaCCZ6Lv4LFxX-2Rnh7WPfJ3XTMUg8eEWLilZO-gYSRSFknrurxRnCYypc4"],["https://encrypted-tbn1.gstatic.com/images?q\u003dtbn:ANd9GcSGvBqFK4czCgdg-4Yyd5-eQvZmPHcw4nyixJB2sQEZFz0XuhET4CwHA_PpOLrw2kHo-Rxd5EL1OM6IFw"]]],[63.985,-22.605556],"IS",0,"Iceland"],[["/m/06flg",4],"Reykjavík",["/m/06flg","Reykjavík",[["https://encrypted-tbn1.gstatic.com/images?q\u003dtbn:ANd9GcRlJC6KzgAknt5cecen-bV6fKYMBcNcPLXmKLOXq02cjaWenaCCZ6Lv4LFxX-2Rnh7WPfJ3XTMUg8eEWLilZO-gYSRSFknrurxRnCYypc4"],["https://encrypted-tbn1.gstatic.com/images?q\u003dtbn:ANd9GcSGvBqFK4czCgdg-4Yyd5-eQvZmPHcw4nyixJB2sQEZFz0XuhET4CwHA_PpOLrw2kHo-Rxd5EL1OM6IFw"]],"Viking history, nightlife \u0026 Blue Lagoon","Capital city with museums tracing Viking history, Hallgrimskirkja church, bars \u0026 Blue Lagoon spa.","REK"],[64.1469868,-21.9407552],"IS",null,"Iceland"],[["LHR",0],"Heathrow Airport",["/m/04jpl","London",[["https://encrypted-tbn1.gstatic.com/images?q\u003dtbn:ANd9GcQYH83YXny8hR4M7k5BMFq4vUT6LNtVABQzgs2pg-hcpSZq3oMBOQK3xh591AAJv2Qx4uvFZUGqOVt4kuoCUOklISunmndJleOoSef_7QE"],["https://encrypted-tbn1.gstatic.com/images?q\u003dtbn:ANd9GcRpN9RbtOSTDqKIPxWc_D6rdSysaWVh6d-NW7yz7yFXKRwh5RN5BpNIoXEwH1XVcFdLWqn6Sm8_Y_zmeg"]]],[51.4775,-0.4613889],"GB",0,"United Kingdom"],[["/m/04jpl",4],"London",["/m/04jpl","London",[["https://encrypted-tbn1.gstatic.com/images?q\u003dtbn:ANd9GcQYH83YXny8hR4M7k5BMFq4vUT6LNtVABQzgs2pg-hcpSZq3oMBOQK3xh591AAJv2Qx4uvFZUGqOVt4kuoCUOklISunmndJleOoSef_7QE"],["https://encrypted-tbn1.gstatic.com/images?q\u003dtbn:ANd9GcRpN9RbtOSTDqKIPxWc_D6rdSysaWVh6d-NW7yz7yFXKRwh5RN5BpNIoXEwH1XVcFdLWqn6Sm8_Y_zmeg"]],"Buckingham Palace \u0026 British Museum","England \u0026 U.K. capital, home to Buckingham Palace, St. Paul’s Cathedral, British Museum \u0026 Hyde Park.","LON"],[51.5072178,-0.1275862],"GB",null,"United Kingdom"],[["LIS",0],"Humberto Delgado Airport",["/m/04llb","Lisbon",[["https://encrypted-tbn0.gstatic.com/images?q\u003dtbn:ANd9GcSG3-nF1u-sTIpnrbZ3a_ly_OcwqDxS9MCOGoiQTX3dJ3ZoIiUsVHqxHC-nmruwZ8aoJZJPM7O5YSmsHR6tp2L_EHV4CnsiNtatHuedKBE"],["https://encrypted-tbn0.gstatic.com/images?q\u003dtbn:ANd9GcQLxT3PIh1TwnGsLrG7G-JQRFMG0zIp4uiQ71FTwf1WQHKROUG_veOYAiGQTLGO36g5OCdu9DUrwHrzaA"]]],[38.7741667,-9.1341667],"PT",0,"Portugal"],[["/m/04llb",4],"Lisbon",["/m/04llb","Lisbon",[["https://encrypted-tbn0.gstatic.com/images?q\u003dtbn:ANd9GcSG3-nF1u-sTIpnrbZ3a_ly_OcwqDxS9MCOGoiQTX3dJ3ZoIiUsVHqxHC-nmruwZ8aoJZJPM7O5YSmsHR6tp2L_EHV4CnsiNtatHuedKBE"],["https://encrypted-tbn0.gstatic.com/images?q\u003dtbn:ANd9GcQLxT3PIh1TwnGsLrG7G-JQRFMG0zIp4uiQ71FTwf1WQHKROUG_veOYAiGQTLGO36g5OCdu9DUrwHrzaA"]],"Alfama, São Jorge Castle \u0026 fado music","Hilly Portuguese capital known for the Alfama district, São Jorge Castle, fado \u0026 nearby beaches.","LIS"],[38.7222524,-9.1393366],"PT",null,"Portugal"],[["LON",0],"Metropolitan Area",["/m/04jpl","London",[["https://encrypted-tbn1.gstatic.com/images?q\u003dtbn:ANd9GcQYH83YXny8hR4M7k5BMFq4vUT6LNtVABQzgs2pg-hcpSZq3oMBOQK3xh591AAJv2Qx4uvFZUGqOVt4kuoCUOklISunmndJleOoSef_7QE"],["https://encrypted-tbn1.gstatic.com/images?q\u003dtbn:ANd9GcRpN9RbtOSTDqKIPxWc_D6rdSysaWVh6d-NW7yz7yFXKRwh5RN5BpNIoXEwH1XVcFdLWqn6Sm8_Y_zmeg"]]],[51.5073509,-0.1277583],"GB",0,"United Kingdom"],[["MAD",0],"Adolfo Suárez Madrid-Barajas Airport",["/m/056_y","Madrid",[["https://encrypted-tbn0.gstatic.com/images?q\u003dtbn:ANd9GcTQE3EB-Tm8oy6YFOIxbhJY-zUj5c54BiVwOKamJRAcogeUidKas9ZrofZJVWQSiCADP_jfvrpPYRJ2PM3p1Sv_lzWcdo4ph1bLVdvASdA"],["https://encrypted-tbn0.gstatic.com/images?q\u003dtbn:ANd9GcQmeVXVi8Qf2opkC-xAX9Z8sqmXLNnCUyEBCH7lY9Du60ePIdqYcgUv_X08z5SxkepA5VBR3iRIMf2cRQ"]]],[40.4997222,-3.5655556],"ES",0,"Spain"],[["/m/056_y",4],"Madrid",["/m/056_y","Madrid",[["https://encrypted-tbn0.gstatic.com/images?q\u003dtbn:ANd9GcTQE3EB-Tm8oy6YFOIxbhJY-zUj5c54BiVwOKamJRAcogeUidKas9ZrofZJVWQSiCADP_jfvrpPYRJ2PM3p1Sv_lzWcdo4ph1bLVdvASdA"],["https://encrypted-tbn0.gstatic.com/images?q\u003dtbn:ANd9GcQmeVXVi8Qf2opkC-xAX9Z8sqmXLNnCUyEBCH7lY9Du60ePIdqYcgUv_X08z5SxkepA5VBR3iRIMf2cRQ"]],"Royal Palace \u0026 Prado museum of art","Spain's capital, home to the Royal Palace \u0026 major art museums like the Prado \u0026 Reina Sofía.","MAD"],[40.4167279,-3.7032905],"ES",null,"Spain"],[["MIA",0],"Miami International Airport",["/m/0f2v0","Miami",[["https://encrypted-tbn2.gstatic.com/images?q\u003dtbn:ANd9GcRScvUK_JtYRXmQWoXHiT98Ajl1KTuUVO40d0Q678OpK1xyyWI8VIkHqzXE9BHfY5R35UpgbeEdcf1IhMDncXwDo29wOABY9MIUzCFLkwU"],["https://encrypted-tbn2.gstatic.com/images?q\u003dtbn:ANd9GcRjsG6ybk9C2oSVnPZUal-6l7EimKLf5gtMAhOumgD16nXBwB4X0lHH3nh-178HKbonabZtnDMdZKfDEQ"]]],[25.7952778,-80.29],"US",0,"United States"],[["/m/0f2v0",4],"Miami",["/m/0f2v0","Miami",[["https://encrypted-tbn2.gstatic.com/images?q\u003dtbn:ANd9GcRScvUK_JtYRXmQWoXHiT98Ajl1KTuUVO40d0Q678OpK1xyyWI8VIkHqzXE9BHfY5R35UpgbeEdcf1IhMDncXwDo29wOABY9MIUzCFLkwU"],["https://encrypted-tbn2.gstatic.com/images?q\u003dtbn:ANd9GcRjsG6ybk9C2oSVnPZUal-6l7EimKLf5gtMAhOumgD16nXBwB4X0lHH3nh-178HKbonabZtnDMdZKfDEQ"]],"South Beach, art deco \u0026 Little Havana","Stylish Florida city known for South Beach, art deco architecture, contemporary art \u0026 Little Havana.","MIA"],[25.7616798,-80.1917902],"US",null,"United States"],[["MIL",0],"Metropolitan Area",["/m/0947l","Milan",[["https://encrypted-tbn1.gstatic.com/images?q\u003dtbn:ANd9GcTsBB8akHX241dOfMh93D9sZuGXUGLXU4NMsSjTo4rnhQrgmRXJssnGLBNbZz1j31_7qNDAYshJ2KaWOL4z4jtiycyGiwD1epOOcsFmmSU"],["https://encrypted-tbn1.gstatic.com/images?q\u003dtbn:ANd9GcTpIuAaYn-1q7jvtJKK9jO9Q0T_a_2HSfh1W2_pk8staOhM7a7JIweVHMECsqtVw5pO_yXdd9g5APWZqA"]]],[45.4654219,9.1859243],"IT",0,"Italy"],[["/m/0947l",4],"Milan",["/m/0947l","Milan",[["https://encrypted-tbn1.gstatic.com/images?q\u003dtbn:ANd9GcTsBB8akHX241dOfMh93D9sZuGXUGLXU4NMsSjTo4rnhQrgmRXJssnGLBNbZz1j31_7qNDAYshJ2KaWOL4z4jtiycyGiwD1epOOcsFmmSU"],["https://encrypted-tbn1.gstatic.com/images?q\u003dtbn:ANd9GcTpIuAaYn-1q7jvtJKK9jO9Q0T_a_2HSfh1W2_pk8staOhM7a7JIweVHMECsqtVw5pO_yXdd9g5APWZqA"]],"Duomo, “The Last Supper” \u0026 high fashion","Northern Italian city known for haute couture, its Gothic Duomo \u0026 da Vinci’s “The Last Supper.”","MIL"],[45.468503,9.1824027],"IT",null,"Italy"],[["MSP",0],"Minneapolis-Saint Paul International Airport",["/m/0fpzwf","Minneapolis",[["https://encrypted-tbn0.gstatic.com/licensed-image?q\u003dtbn:ANd9GcRxvm0_9fJqFuNvav6B7Q6fm5GQbJwjHpgvJJAs9GI_MhH4FrP4Heo1onsT6SlkX4xADpCTFEPjo8DQq_G7mFWx9Tnb6roy-zKuajI4DeI"],["https://encrypted-tbn0.gstatic.com/licensed-image?q\u003dtbn:ANd9GcSVyCsBCTHbKZsspgUY86CWOcI6diKCmGzNKpYv9yLVTHTf3Mb2b9ikbsifrA_7naEhUVrakEZ-IQ5FN12PxhZstRCg7HVFt8LJuwqD1Gg"]]],[44.8819444,-93.221667],"US",0,"United States"],[["/m/0fpzwf",4],"Minneapolis",["/m/0fpzwf","Minneapolis",[["https://encrypted-tbn0.gstatic.com/licensed-image?q\u003dtbn:ANd9GcRxvm0_9fJqFuNvav6B7Q6fm5GQbJwjHpgvJJAs9GI_MhH4FrP4Heo1onsT6SlkX4xADpCTFEPjo8DQq_G7mFWx9Tnb6roy-zKuajI4DeI"],["https://encrypted-tbn0.gstatic.com/licensed-image?q\u003dtbn:ANd9GcSVyCsBCTHbKZsspgUY86CWOcI6diKCmGzNKpYv9yLVTHTf3Mb2b9ikbsifrA_7naEhUVrakEZ-IQ5FN12PxhZstRCg7HVFt8LJuwqD1Gg"]],"Twin City known for Chain of Lakes \u0026 art","Set along the Chain of Lakes, this Twin City in Minnesota offers many art museums \u0026 cultural sites.","MSP"],[44.977753,-93.2650108],"US",null,"United States"],[["MUC",0],"Munich International Airport",["/m/02h6_6p","Munich",[["https://encrypted-tbn3.gstatic.com/images?q\u003dtbn:ANd9GcSmyu128XY69CmkxXWLN30kZIXt_igqHXXrISZvesFbLyebUoW5YamdDfnM9UJHOYcYOR4MXfclej8aS3Y7CQ9v4rQeWEXhZzJiZgUsk50"],["https://encrypted-tbn3.gstatic.com/images?q\u003dtbn:ANd9GcScUfpZZ88ASyCVtBpdQ0iGyCky9wd0yzmrrLqseG_jjfV4bLti0pnBGVdlHQAqKdsJ1N_ckz3BT2ZsyA"]]],[48.3538889,11.7861111],"DE",0,"Germany"],[["/m/02h6_6p",4],"Munich",["/m/02h6_6p","Munich",[["https://encrypted-tbn3.gstatic.com/images?q\u003dtbn:ANd9GcSmyu128XY69CmkxXWLN30kZIXt_igqHXXrISZvesFbLyebUoW5YamdDfnM9UJHOYcYOR4MXfclej8aS3Y7CQ9v4rQeWEXhZzJiZgUsk50"],["https://encrypted-tbn3.gstatic.com/images?q\u003dtbn:ANd9GcScUfpZZ88ASyCVtBpdQ0iGyCky9wd0yzmrrLqseG_jjfV4bLti0pnBGVdlHQAqKdsJ1N_ckz3BT2ZsyA"]],"Hofbräuhaus, Oktoberfest \u0026 the Residenz","Bavarian capital known for Oktoberfest, the Hofbräuhaus beer hall \u0026 the Residenz palace \u0026 museum.","MUC"],[48.1351253,11.5819806],"DE",null,"Germany"],[["MXP",0],"Milano Malpensa Airport",["/m/0947l","Milan",[["https://encrypted-tbn1.gstatic.com/images?q\u003dtbn:ANd9GcTsBB8akHX241dOfMh93D9sZuGXUGLXU4NMsSjTo4rnhQrgmRXJssnGLBNbZz1j31_7qNDAYshJ2KaWOL4z4jtiycyGiwD1epOOcsFmmSU"],["https://encrypted-tbn1.gstatic.com/images?q\u003dtbn:ANd9GcTpIuAaYn-1q7jvtJKK9jO9Q0T_a_2HSfh1W2_pk8staOhM7a7JIweVHMECsqtVw5pO_yXdd9g5APWZqA"]]],[45.63,8.72305556],"IT",0,"Italy"],[["NYC",0],"Metropolitan Area",["/m/02_286","New York",[["https://encrypted-tbn1.gstatic.com/images?q\u003dtbn:ANd9GcQEaUa9NsdPWGpAUGkTApkZDT_4M6_6V8wTcC0v1b1wJAJX-BuMSiipXbsoznGgcI1xLOc5QiTcR_xovexgjdOz0gqQe0tRQ9h0bUkZ07Q"],["https://encrypted-tbn1.gstatic.com/images?q\u003dtbn:ANd9GcRa1dwH1NZQk4dsbPiyA9Vrq2RX75jXSZ-OkHn7NkLHl-11HercqDXoZ4p2cDxJkH6vca2degawrCzHEQ"]]],[40.7127837,-74.0059413],"US",0,"United States"],[["ORD",0],"Chicago O'Hare International Airport",["/m/01_d4","Chicago",[["https://encrypted-tbn2.gstatic.com/images?q\u003dtbn:ANd9GcR0CK6-eZWtnTJdtBk0BnPl1NeBcRul1YiurNp0AEgxFjNRleXR3vb2VV6vc5Uk51C0AhYN6AZAQKz6FJ-NQfbjVf8HQQ96ZH3WYIS-Rw0"],["https://encrypted-tbn2.gstatic.com/images?q\u003dtbn:ANd9GcTDuw95ynLqGCkZRzt9XuWXGBs8qWhw_1UZkMrCRAQp3rojEZBpwitHM8GAMBXgKhSKFgJZcXZ3qmYs2g"]]],[41.9794444,-87.9075],"US",0,"United States"],[["PAR",0],"Metropolitan Area",["/m/05qtj","Paris",[["https://encrypted-tbn3.gstatic.com/images?q\u003dtbn:ANd9GcSyQJ-woNs0iO22mPSkmRUM5gcsTbbYeypQ6BBTeFxXr90mqTxZl57Fdq2CDuLn4w7cKZ8TT9_zZhOpF57rIpA7yWKQnqKvkKIf9Y-qJDo"],["https://encrypted-tbn3.gstatic.com/images?q\u003dtbn:ANd9GcQGx8ii2KbSDdbdzfKye5oDN2bwBA6audqI7XUEf2iMRZezpn_ZbQe1ZIuvUSH-8XOMe958umDwSsAF1w"]]],[48.856614,2.3522219000000004],"FR",0,"France"],[["RDU",0],"Raleigh-Durham International Airport",["/m/0fvyg","Raleigh",[["https://encrypted-tbn0.gstatic.com/images?q\u003dtbn:ANd9GcS6z-xlYQt-6a4mo_YN7F3B47ZHoKMyxQdTxiSkt6SwAUvZKQb47ajtDacFZVPFxS025qCdQ6MgN6YrqaVDHEHSFexAYOXjAIaJeyF4bKI"],["https://encrypted-tbn0.gstatic.com/images?q\u003dtbn:ANd9GcSAeLP5M69Jg8_Cd6-HqhUon5v57KHwg4Eft_PrDQpMIlV9tiPzO1YTm0iFNPY3GzpKS_cowzTMDwKU_Q"]]],[35.8777778,-78.7875],"US",0,"United States"],[["/m/0fvyg",4],"Raleigh",["/m/0fvyg","Raleigh",[["https://encrypted-tbn0.gstatic.com/images?q\u003dtbn:ANd9GcS6z-xlYQt-6a4mo_YN7F3B47ZHoKMyxQdTxiSkt6SwAUvZKQb47ajtDacFZVPFxS025qCdQ6MgN6YrqaVDHEHSFexAYOXjAIaJeyF4bKI"],["https://encrypted-tbn0.gstatic.com/images?q\u003dtbn:ANd9GcSAeLP5M69Jg8_Cd6-HqhUon5v57KHwg4Eft_PrDQpMIlV9tiPzO1YTm0iFNPY3GzpKS_cowzTMDwKU_Q"]],"North Carolina Capitol \u0026 museums","North Carolina capital with the State Capitol Building, museums \u0026 JC Raulston Arboretum.","RDU"],[35.7795897,-78.6381787],"US",null,"United States"],[["REK",0],"Metropolitan Area",["/m/06flg","Reykjavík",[["https://encrypted-tbn1.gstatic.com/images?q\u003dtbn:ANd9GcRlJC6KzgAknt5cecen-bV6fKYMBcNcPLXmKLOXq02cjaWenaCCZ6Lv4LFxX-2Rnh7WPfJ3XTMUg8eEWLilZO-gYSRSFknrurxRnCYypc4"],["https://encrypted-tbn1.gstatic.com/images?q\u003dtbn:ANd9GcSGvBqFK4czCgdg-4Yyd5-eQvZmPHcw4nyixJB2sQEZFz0XuhET4CwHA_PpOLrw2kHo-Rxd5EL1OM6IFw"]]],[64.133333,-21.933333],"IS",0,"Iceland"],[["ROM",0],"Metropolitan Area",["/m/06c62","Rome",[["https://encrypted-tbn1.gstatic.com/images?q\u003dtbn:ANd9GcRM_5snkSVZsnpG8dhW0NGx_Pdwk592nbBjmyqu-UxZDclvuBr6HXfXd0Fm7TYGVQpVCCr4RC6TGTmOgyP6KwpvZr0tGGnpZ7ukzP8RPLA"],["https://encrypted-tbn1.gstatic.com/images?q\u003dtbn:ANd9GcT2IU9ZUmvhvThfVJdnmh0sazh2RYI04-GSv0_GLCW7m3TnPpi1XYRNkIuXyL-bdJRgPn7Akcbg6zmDzw"]]],[41.9027835,12.4963655],"IT",0,"Italy"],[["SNN",0],"Shannon Airport",["/m/02lpw5","Shannon",[["https://encrypted-tbn1.gstatic.com/images?q\u003dtbn:ANd9GcRXbsV3NvuV6jY6gUdaNuod9c-qELpGbesYWfCmwBZ_U4pPC37THNzDsfKUGPFDnNgIxEItLvSAb-8L2f8eEpjqMvxp4HyMA2Dnv0oHtUI"],["https://encrypted-tbn1.gstatic.com/images?q\u003dtbn:ANd9GcTIilMyTsbQVzA3ZwwMMOhYxUqq3w5F8MghxyvvtzqbTx8fgi7Ak5C5YFumtNKaN--k681hCauD8MNsZg"]]],[52.7019444,-8.9247222],"IE",0,"Ireland"],[["/m/02lpw5",4],"Shannon",["/m/02lpw5","Shannon",[["https://encrypted-tbn1.gstatic.com/images?q\u003dtbn:ANd9GcRXbsV3NvuV6jY6gUdaNuod9c-qELpGbesYWfCmwBZ_U4pPC37THNzDsfKUGPFDnNgIxEItLvSAb-8L2f8eEpjqMvxp4HyMA2Dnv0oHtUI"],["https://encrypted-tbn1.gstatic.com/images?q\u003dtbn:ANd9GcTIilMyTsbQVzA3ZwwMMOhYxUqq3w5F8MghxyvvtzqbTx8fgi7Ak5C5YFumtNKaN--k681hCauD8MNsZg"]],"Atlantic AirVenture \u0026 Bunratty Castle","Irish town known for the Atlantic AirVenture complex, plus nearby Bunratty \u0026 Knappogue castles.","SNN"],[52.7117822,-8.8783365],"IE",null,"Ireland"],[["WAS",0],"Metropolitan Area",["/m/0rh6k","Washington",[["https://encrypted-tbn1.gstatic.com/images?q\u003dtbn:ANd9GcRMLLOliMVP16YVOyMBlzc0Gmxx-R5fU2bSGBN2tw9x-6tWr0q5I3bRnaMOot3V_SMDxjwVNjxd3aIlFxHtZL0Yc8rVnZAQAs2upGkhIZ0"],["https://encrypted-tbn1.gstatic.com/images?q\u003dtbn:ANd9GcRG0OK4wTkRsqDVobvhtBOPZMDsUETpgJ7jPzOA--4D-HL-0BVkyp4S9gvw7CBWMKyfFVS0lLRn7pmR-Q"]]],[38.9071923,-77.0368707],"US",0,"United States"],[["WAW",0],"Warsaw Chopin Airport",["/m/081m_","Warsaw",[["https://encrypted-tbn0.gstatic.com/images?q\u003dtbn:ANd9GcTpYgCZaR1AQIUNfZw69CxHGT2OB0VmzHyYCmfyHLlH1lJ2D1OlspuNu2uN7sK40UqPj5Z_kAZhiUpZUUYlMqsL3_cZdxPEjp86EGSCGi4"],["https://encrypted-tbn0.gstatic.com/images?q\u003dtbn:ANd9GcSHx25TjZC37XYjd35zw7q_e_LkTtU5W8UU5aNruIEFZ8jijgQfjKJekztMYYqNnWAaSzk5IOJCZwpmhg"]]],[52.1658333,20.9672222],"PL",0,"Poland"],[["/m/081m_",4],"Warsaw",["/m/081m_","Warsaw",[["https://encrypted-tbn0.gstatic.com/images?q\u003dtbn:ANd9GcTpYgCZaR1AQIUNfZw69CxHGT2OB0VmzHyYCmfyHLlH1lJ2D1OlspuNu2uN7sK40UqPj5Z_kAZhiUpZUUYlMqsL3_cZdxPEjp86EGSCGi4"],["https://encrypted-tbn0.gstatic.com/images?q\u003dtbn:ANd9GcSHx25TjZC37XYjd35zw7q_e_LkTtU5W8UU5aNruIEFZ8jijgQfjKJekztMYYqNnWAaSzk5IOJCZwpmhg"]],"Wilanów Palace, Old Town \u0026 museums","Poland’s capital with a rebuilt Old Town, noted museums \u0026 royal sites including Wilanów Palace.","WAW"],[52.2296756,21.0122287],"PL",null,"Poland"],[["ZRH",0],"Zurich Airport",["/m/08966","Zürich",[["https://encrypted-tbn1.gstatic.com/images?q\u003dtbn:ANd9GcRqRPVbtpLlsqXRSs-iYHZmiU2ke8OOzQRoYeU-uCnKtlNNCFTFVrh49_PZLZIJ1DIiA3PBicI1_9uy0JvCaRFEncw3D3fo_PuwaaOFqwI"],["https://encrypted-tbn1.gstatic.com/images?q\u003dtbn:ANd9GcSCRBubxyDtBeVMRuz8mYJfJ6BXcFZgrTOweDpS6aFKjmb4NETUN-HyOzK-pGI48nh0A-laBLn2qEFiEw"]]],[47.4647222,8.54916667],"CH",0,"Switzerland"],[["/m/08966",4],"Zürich",["/m/08966","Zürich",[["https://encrypted-tbn1.gstatic.com/images?q\u003dtbn:ANd9GcRqRPVbtpLlsqXRSs-iYHZmiU2ke8OOzQRoYeU-uCnKtlNNCFTFVrh49_PZLZIJ1DIiA3PBicI1_9uy0JvCaRFEncw3D3fo_PuwaaOFqwI"],["https://encrypted-tbn1.gstatic.com/images?q\u003dtbn:ANd9GcSCRBubxyDtBeVMRuz8mYJfJ6BXcFZgrTOweDpS6aFKjmb4NETUN-HyOzK-pGI48nh0A-laBLn2qEFiEw"]],"Banking center on the Limmat River","Global finance center with Old Town on the Limmat River, home to Fraumünster church \u0026 Landesmuseum.","ZRH"],[47.3768866,8.541694],"CH",null,"Switzerland"]],["EAEaBAgDEAEhAAAAAABockAqA1VTRDIAUAFiGxoLCgQIAxABEAGIAQEqDBgBIgNKRksqA0xIUmgAcLft4DJwkd3WMnDH0N8y",0],null,0,null,null,1,null,[[null,295]],[["AA","American","https://www.aa.com/i18n/travel-info/special-assistance/special-assistance.jsp"],["BA","British Airways","https://www.britishairways.com/en-gb/information/travel-assistance"],["DL","Delta","https://www.delta.com/us/en/accessible-travel-services/overview"],["B6","JetBlue","https://www.jetblue.com/at-the-airport/accessibility-assistance"],["VS","Virgin Atlantic","https://help.virginatlantic.com/gb/en/special-assistance.html"]],null,null,null,[[null,295],"CjRITWg0Y0tvZnpWQW9BSXI1WWdCRy0tLS0tLS0tcGZia3IxNkFBQUFBR3F2b29NTlpRTW1BEhZjb21wcmVoZW5zaXZlbmVzc19sdXJlGgsIiuYBEAIaA1VTRDgdcIrmAQ\u003d\u003d"]], sideChannel: {}});</script>+</body></html>diff --git a/tests/search/test_booking_options.py b/tests/search/test_booking_options.pyindex 02d4a25..4ec72b8 100644--- a/tests/search/test_booking_options.py+++ b/tests/search/test_booking_options.py@@ -2,7 +2,7 @@import jsonimport urllib.parse-from datetime import datetime+from datetime import datetime, time, timedeltaimport pytest@@ -18,6 +18,12 @@ from fli.models import (TripType,)from fli.search.flights import SearchFlights, _try_parse_booking_row+from tests.search._pages import as_search_page++# Segment travel dates are validated against today, so keep the fixtures+# relative — hardcoded dates rot the suite the moment they go past.+OUT_DATE = (datetime.now() + timedelta(days=30)).date()+RET_DATE = OUT_DATE + timedelta(days=4)def _round_trip_filters():@@ -27,8 +33,8 @@ def _round_trip_filters():flight_number="171",departure_airport=Airport.JFK,arrival_airport=Airport.LAX,- departure_datetime=datetime(2026, 7, 15, 6, 0),- arrival_datetime=datetime(2026, 7, 15, 9, 1),+ departure_datetime=datetime.combine(OUT_DATE, time(6, 0)),+ arrival_datetime=datetime.combine(OUT_DATE, time(9, 1)),duration=361,)leg_in = FlightLeg(@@ -36,8 +42,8 @@ def _round_trip_filters():flight_number="28",departure_airport=Airport.LAX,arrival_airport=Airport.JFK,- departure_datetime=datetime(2026, 7, 19, 15, 15),- arrival_datetime=datetime(2026, 7, 19, 23, 54),+ departure_datetime=datetime.combine(RET_DATE, time(15, 15)),+ arrival_datetime=datetime.combine(RET_DATE, time(23, 54)),duration=339,)sel_out = FlightResult(@@ -57,13 +63,13 @@ def _round_trip_filters():seg_out = FlightSegment(departure_airport=[[Airport.JFK, 0]],arrival_airport=[[Airport.LAX, 0]],- travel_date="2026-07-15",+ travel_date=OUT_DATE.isoformat(),selected_flight=sel_out,)seg_in = FlightSegment(departure_airport=[[Airport.LAX, 0]],arrival_airport=[[Airport.JFK, 0]],- travel_date="2026-07-19",+ travel_date=RET_DATE.isoformat(),selected_flight=sel_in,)return FlightSearchFilters(@@ -102,9 +108,9 @@ class TestEncodeBookingPayload:assert len(segments) == 2# selected_flight legs sit at segment[8]; verify each leg's basic fields.out_sel = segments[0][8]- assert out_sel == [["JFK", "2026-07-15", "LAX", None, "AA", "171"]]+ assert out_sel == [["JFK", OUT_DATE.isoformat(), "LAX", None, "AA", "171"]]in_sel = segments[1][8]- assert in_sel == [["LAX", "2026-07-19", "JFK", None, "AA", "28"]]+ assert in_sel == [["LAX", RET_DATE.isoformat(), "JFK", None, "AA", "28"]]class TestGetBookingOptionsTokenGuard:@@ -294,14 +300,12 @@ class TestGetBookingOptionsSessionCaching:None,],]- # Wrap as the chunked outer the client expects.- outer_inner_json = json.dumps(fake_inner, separators=(",", ":"))- outer = [["wrb.fr", None, outer_inner_json]]- body = ")]}'\n\n" + json.dumps(outer)+ # Serve it the way the page transport reads it: a ds:1 blob.+ body = as_search_page(fake_inner)- with patch.object(sf.client, "post") as mock_post:+ with patch.object(sf.client, "get") as mock_get:mock_response = type("R", (), {"text": body, "raise_for_status": lambda s: None})()- mock_post.return_value = mock_response+ mock_get.return_value = mock_responsetry:sf.search(_round_trip_filters())except Exception:diff --git a/tests/search/test_client.py b/tests/search/test_client.pyindex b05174e..d5d2297 100644--- a/tests/search/test_client.py+++ b/tests/search/test_client.py@@ -2,6 +2,7 @@from __future__ import annotations+import osfrom unittest.mock import MagicMockimport pytest@@ -118,3 +119,77 @@ class TestGetClientSingleton:client_module.client = Nonec2 = get_client()assert c1 is not c2+++class TestConsentCookie:+ """EU/EEA IPs hit Google's consent interstitial without a SOCS cookie."""++ def test_session_carries_socs_cookie_for_google(self, monkeypatch):+ monkeypatch.setattr(client_module, "SOCS_COOKIE", "TESTSOCS")+ session = get_client()._session()+ assert session.cookies.get("SOCS", domain=".google.com") == "TESTSOCS"++ def test_empty_env_value_sends_no_cookie(self, monkeypatch):+ monkeypatch.setattr(client_module, "SOCS_COOKIE", "")+ session = get_client()._session()+ assert session.cookies.get("SOCS", domain=".google.com") is None++ @staticmethod+ def _reimport_client(env_value: str | None):+ """Re-evaluate the module's import-time env read, in a throwaway module.++ ``importlib.reload`` would rebind the real ``fli.search.client``,+ resetting the process-wide client singleton for every later test.+ Executing the source into a fresh module object exercises the same+ import-time expression while leaving ``sys.modules`` untouched.+ """+ import importlib.util+ import os++ previous = os.environ.get("FLI_SOCS_COOKIE")+ if env_value is None:+ os.environ.pop("FLI_SOCS_COOKIE", None)+ else:+ os.environ["FLI_SOCS_COOKIE"] = env_value+ try:+ spec = importlib.util.spec_from_file_location(+ "fli_client_env_probe", client_module.__file__+ )+ module = importlib.util.module_from_spec(spec)+ spec.loader.exec_module(module)+ return module+ finally:+ if previous is None:+ os.environ.pop("FLI_SOCS_COOKIE", None)+ else:+ os.environ["FLI_SOCS_COOKIE"] = previous++ def test_empty_env_var_disables_the_cookie(self):+ """``FLI_SOCS_COOKIE=""`` must mean "send nothing", not "use the default"."""+ module = self._reimport_client("")+ assert module.SOCS_COOKIE == ""+ session = module.Client()._session()+ assert session.cookies.get("SOCS", domain=".google.com") is None++ def test_env_var_overrides_the_default(self):+ module = self._reimport_client("OVERRIDDEN")+ assert module.SOCS_COOKIE == "OVERRIDDEN"++ def test_unset_env_var_keeps_the_cookie_on(self):+ """The author's default stays on — EU IPs otherwise hit the consent page.++ Resolved from a clean environment rather than from the module constant,+ so the test does not fail for a developer who exports the variable.+ """+ module = self._reimport_client(None)+ assert module.SOCS_COOKIE == module.DEFAULT_SOCS_COOKIE+ assert module.SOCS_COOKIE++ def test_process_client_module_is_untouched(self):+ """The probes above must not disturb the real module or its singleton."""+ before = client_module.client+ self._reimport_client("")+ assert client_module.client is before+ assert client_module.SOCS_COOKIE == os.environ.get(+ "FLI_SOCS_COOKIE", client_module.DEFAULT_SOCS_COOKIE+ )diff --git a/tests/search/test_date_sweep.py b/tests/search/test_date_sweep.pynew file mode 100644index 0000000..3081e79--- /dev/null+++ b/tests/search/test_date_sweep.py@@ -0,0 +1,723 @@+"""Offline tests for the per-date sweep in :class:`fli.search.SearchDates`.++The page transport has no calendar grid, so a date search prices every date+with its own page fetch. These tests feed synthetic ``ds:1`` payloads through+a stub client and cover the failure, cost and filtering behaviour of that+sweep — none of them touch the network.+"""++from __future__ import annotations++import logging+import threading+from datetime import datetime, timedelta+from typing import Any++import pytest++from fli.models import (+ Airline,+ Airport,+ DateSearchFilters,+ FlightSegment,+ PassengerInfo,+ TimeRestrictions,+ TripType,+)+from fli.search import _tfs as tfs_module+from fli.search import dates as dates_module+from fli.search._concurrency import get_executor+from fli.search.exceptions import (+ SearchClientError,+ SearchConnectionError,+ SearchParseError,+)+from tests.search._pages import as_search_page++# Far enough out that every date in the widest range below is bookable.+FIRST_DAY = datetime.now().replace(hour=0, minute=0, second=0, microsecond=0) + timedelta(days=30)+++# ---------------------------------------------------------------------------+# Synthetic payload builders (positions mirror .reverse-eng/notes/response_map.md)+# ---------------------------------------------------------------------------+++def _leg(airline: str = "AA", flight_number: str = "100", hour: int = 9) -> list:+ leg = [None] * 33+ leg[3] = "JFK"+ leg[6] = "LAX"+ leg[8] = [hour, 0]+ leg[10] = [hour + 3, 0]+ leg[11] = 180+ leg[20] = [2026, 7, 15]+ leg[21] = [2026, 7, 15]+ leg[22] = [airline, flight_number, None, "Carrier"]+ return leg+++def _row(price: float, airline: str = "AA", hour: int = 9) -> list:+ legs = [_leg(airline=airline, hour=hour)]+ detail = [None] * 25+ detail[0] = airline+ detail[1] = ["Carrier"]+ detail[2] = legs+ detail[9] = 180+ row = [None] * 11+ row[0] = detail+ row[1] = [[None, price], None]+ return row+++def _page(rows: list) -> str:+ """Wrap flight rows as the ``ds:1`` payload of a rendered search page."""+ return as_search_page([None, None, [rows], None])+++class _Response:+ def __init__(self, text: str):+ self.text = text++ def raise_for_status(self) -> None:+ return None+++class StubClient:+ """Serves a canned page (or raises) for every request, counting calls."""++ def __init__(self, body: str | None = None, error: BaseException | None = None):+ """Serve ``body`` for every request, or raise ``error`` instead."""+ self.body = body+ self.error = error+ self.calls = 0+ self._lock = threading.Lock()++ def get(self, url: str, **kwargs: Any) -> _Response:+ with self._lock:+ self.calls += 1+ if self.error is not None:+ raise self.error+ return _Response(self.body or "")+++def _filters(days: int, **kwargs) -> DateSearchFilters:+ """One-way date filters spanning ``days`` dates starting at FIRST_DAY."""+ return DateSearchFilters(+ trip_type=TripType.ONE_WAY,+ passenger_info=PassengerInfo(adults=1),+ flight_segments=[+ FlightSegment(+ departure_airport=[[Airport.JFK, 0]],+ arrival_airport=[[Airport.LAX, 0]],+ travel_date=FIRST_DAY.strftime("%Y-%m-%d"),+ time_restrictions=kwargs.pop("time_restrictions", None),+ )+ ],+ from_date=FIRST_DAY.strftime("%Y-%m-%d"),+ to_date=(FIRST_DAY + timedelta(days=days - 1)).strftime("%Y-%m-%d"),+ **kwargs,+ )+++def _search_with(client: StubClient) -> dates_module.SearchDates:+ search = dates_module.SearchDates()+ search.client = client+ return search+++# ---------------------------------------------------------------------------+# 1. A total transport failure must not read as "no dates"+# ---------------------------------------------------------------------------+++class TestTotalFailureIsLoud:+ def test_every_date_raising_surfaces_an_error(self):+ """A dead transport used to return None — indistinguishable from "no flights"."""+ client = StubClient(error=SearchConnectionError("connection refused"))+ with pytest.raises(SearchClientError) as excinfo:+ _search_with(client).search(_filters(days=5))+ message = str(excinfo.value)+ assert "5" in message, f"error should say how many dates failed: {message}"+ assert "connection refused" in message, f"error should say why: {message}"++ def test_every_date_missing_the_payload_surfaces_an_error(self):+ """A consent/blocked page carries no ds:1 blob — that is a failure, not emptiness."""+ client = StubClient(body="<html>no data callback here</html>")+ with pytest.raises(SearchClientError) as excinfo:+ _search_with(client).search(_filters(days=4))+ message = str(excinfo.value)+ assert "4" in message+ assert "ds:1" in message++ def test_one_bad_date_is_skipped_not_fatal(self):+ """Individual failures stay warnings as long as some date priced."""+ good = _page([_row(120.0)])++ class _Flaky(StubClient):+ def get(self, url: str, **kwargs: Any) -> _Response:+ with self._lock:+ self.calls += 1+ n = self.calls+ if n == 2:+ raise SearchConnectionError("transient")+ return _Response(good)++ results = _search_with(_Flaky()).search(_filters(days=3))+ assert results is not None+ assert len(results) == 2, "the two healthy dates should still be priced"++ def test_dates_without_flights_are_not_failures(self):+ """A page that parses but has no rows means "no flights", not a broken transport."""+ results = _search_with(StubClient(_page([]))).search(_filters(days=3))+ assert results is None+++# ---------------------------------------------------------------------------+# 2. Row extraction must be total+# ---------------------------------------------------------------------------+++class TestRowExtractionIsTotal:+ @pytest.mark.parametrize(+ "payload",+ [+ [None, None, [], None], # empty container — payload[2][0] used to IndexError+ [None, None, None, None],+ [None, None, ["not-a-row-list"], None],+ [None, None], # short payload+ ],+ ids=["empty-container", "null-slots", "rows-not-a-list", "short-payload"],+ )+ def test_odd_payload_shapes_yield_no_results_without_raising(self, payload):+ client = StubClient(as_search_page(payload))+ assert _search_with(client).search(_filters(days=3)) is None+++# ---------------------------------------------------------------------------+# 3. One level of parallelism — nested pools deadlock+# ---------------------------------------------------------------------------+++class TestSingleLevelParallelism:+ """The sweep must map the whole range once, never once per chunk again.++ Nesting ``parallel_map`` inside a ``parallel_map`` worker deadlocks: both+ levels share one bounded pool, so outer tasks can hold every worker while+ blocking on inner tasks that can never be scheduled.++ These are structural assertions rather than a "does it hang?" test on+ purpose. A real deadlock parks non-daemon pool workers inside a task, and+ the interpreter then hangs in ``threading._shutdown`` joining them — so a+ behavioural test would hang CI on regression no matter how its own timeout+ is written, and detaching the workers from+ ``concurrent.futures.thread._threads_queues`` does not prevent it. The+ assertions below catch the same regression in milliseconds.+ """++ def _counted_map(self, mp, sizes: list[int]):+ real = dates_module.parallel_map++ def _counting(fn, items, **kwargs):+ materialised = list(items)+ sizes.append(len(materialised))+ return real(fn, materialised, **kwargs)++ mp.setattr(dates_module, "parallel_map", _counting)++ def test_sweep_submits_one_batch_of_work(self):+ """70 dates spanning two chunks are mapped by a single call."""+ sizes: list[int] = []+ client = StubClient(_page([_row(150.0)]))+ search = _search_with(client)+ with pytest.MonkeyPatch.context() as mp:+ self._counted_map(mp, sizes)+ search.search(_filters(days=70))+ assert sizes == [70], f"expected one flat map over 70 dates, got {sizes}"++ def test_no_parallel_map_runs_inside_a_worker(self):+ """Pin the property that actually causes the deadlock: no nesting.++ Fails on the old shape, where the per-chunk worker called+ ``parallel_map`` again while running on a pool thread.+ """+ depth = threading.local()+ nested: list[str] = []+ real = dates_module.parallel_map++ def _tracking(fn, items, **kwargs):+ if getattr(depth, "inside", False):+ nested.append(threading.current_thread().name)++ def _wrapped(item):+ depth.inside = True+ try:+ return fn(item)+ finally:+ depth.inside = False++ return real(_wrapped, list(items), **kwargs)++ client = StubClient(_page([_row(150.0)]))+ search = _search_with(client)+ with pytest.MonkeyPatch.context() as mp:+ mp.setattr(dates_module, "parallel_map", _tracking)+ results = search.search(_filters(days=70))+ assert results is not None and len(results) == 70+ assert nested == [], f"parallel_map was called from inside a worker: {nested}"+++# ---------------------------------------------------------------------------+# 4. Bounded cost+# ---------------------------------------------------------------------------+++class TestDateCountCap:+ def test_range_over_the_cap_is_refused(self):+ client = StubClient(_page([_row(150.0)]))+ with pytest.raises(ValueError) as excinfo:+ _search_with(client).search(_filters(days=dates_module.MAX_DATES_PER_SEARCH + 1))+ message = str(excinfo.value)+ assert str(dates_module.MAX_DATES_PER_SEARCH) in message+ assert "narrow" in message.lower()+ assert client.calls == 0, "the cap must be checked before any fetch"++ def test_range_at_the_cap_is_allowed(self):+ client = StubClient(_page([_row(150.0)]))+ results = _search_with(client).search(_filters(days=dates_module.MAX_DATES_PER_SEARCH))+ assert results is not None and len(results) == dates_module.MAX_DATES_PER_SEARCH++ def test_default_cap_is_93(self):+ assert dates_module.MAX_DATES_PER_SEARCH == 93++ def test_cli_default_range_fits_under_the_cap(self):+ import inspect++ from fli.cli.commands.dates import dates as dates_command++ params = inspect.signature(dates_command).parameters+ start = datetime.strptime(params["start_date"].default, "%Y-%m-%d")+ end = datetime.strptime(params["end_date"].default, "%Y-%m-%d")+ assert (end - start).days + 1 <= dates_module.MAX_DATES_PER_SEARCH+++# ---------------------------------------------------------------------------+# 5. Client-side filters apply to the sweep too+# ---------------------------------------------------------------------------+++class TestClientSideFiltersApplyToDates:+ """``tfs`` has no field for these, so the sweep must filter after fetching.++ Without it, the cheapest date price is taken over rows the caller asked+ to exclude — the filter is reported as applied and silently is not.+ """++ def _mixed_page(self) -> str:+ return _page(+ [+ _row(100.0, airline="AA", hour=6),+ _row(500.0, airline="DL", hour=20),+ ]+ )++ def test_airline_include_filters_before_taking_the_minimum(self):+ client = StubClient(self._mixed_page())+ results = _search_with(client).search(_filters(days=2, airlines=[Airline.DL]))+ assert results is not None+ assert [r.price for r in results] == [500.0, 500.0]++ def test_airline_exclude_filters_before_taking_the_minimum(self):+ client = StubClient(self._mixed_page())+ results = _search_with(client).search(_filters(days=2, airlines_exclude=[Airline.AA]))+ assert results is not None+ assert [r.price for r in results] == [500.0, 500.0]++ def test_departure_window_filters_before_taking_the_minimum(self):+ client = StubClient(self._mixed_page())+ results = _search_with(client).search(+ _filters(+ days=2,+ time_restrictions=TimeRestrictions(earliest_departure=8, latest_departure=23),+ )+ )+ assert results is not None+ assert [r.price for r in results] == [500.0, 500.0]++ def test_max_duration_filters_before_taking_the_minimum(self):+ page = _page([_row(100.0, airline="AA"), _row(500.0, airline="DL")])+ client = StubClient(page)+ # Both synthetic rows last 180 minutes, so a 60-minute ceiling drops+ # every row and the date prices to nothing rather than to $100.+ results = _search_with(client).search(_filters(days=2, max_duration=60))+ assert results is None++ def test_filters_survive_the_chunk_split(self):+ """Chunk copies must carry every filter, not just the ones re-listed."""+ client = StubClient(self._mixed_page())+ results = _search_with(client).search(_filters(days=70, airlines_exclude=[Airline.AA]))+ assert results is not None+ assert {r.price for r in results} == {500.0}+++# ---------------------------------------------------------------------------+# Transient pages without a ds:1 payload (fix round 1, F2)+# ---------------------------------------------------------------------------+++class _Sequence(StubClient):+ """Serves a scripted list of bodies, one per call, repeating the last."""++ def __init__(self, bodies: list[str]):+ """Record the scripted bodies."""+ super().__init__()+ self.bodies = bodies++ def get(self, url: str, **kwargs: Any) -> _Response:+ with self._lock:+ index = min(self.calls, len(self.bodies) - 1)+ self.calls += 1+ return _Response(self.bodies[index])+++def no_backoff(monkeypatch):+ """Record retry delays instead of sleeping them."""+ slept: list[float] = []+ monkeypatch.setattr(tfs_module, "_sleep", slept.append)+ return slept+++class TestTransientPageRetry:+ """One page in ~60 comes back 200 with no ds:1 blob; retry just that case."""++ BLANK = "<html>no data callback here</html>"++ def test_healthy_sweep_stays_one_request_per_date(self, no_backoff):+ client = StubClient(_page([_row(150.0)]))+ results = _search_with(client).search(_filters(days=5))+ assert results is not None and len(results) == 5+ assert client.calls == 5, "a healthy sweep must not pay for the retry"+ assert no_backoff == []++ def test_missing_once_then_present_succeeds_in_two_fetches(self, no_backoff):+ client = _Sequence([self.BLANK, _page([_row(150.0)])])+ results = _search_with(client).search(_filters(days=1))+ assert results is not None and len(results) == 1+ assert client.calls == 2+ assert no_backoff == [0.5]++ def test_missing_three_times_gives_up_after_exactly_three_fetches(self, no_backoff):+ client = _Sequence([self.BLANK])+ with pytest.raises(SearchClientError) as excinfo:+ _search_with(client).search(_filters(days=1))+ assert client.calls == 3+ assert no_backoff == [0.5, 1.5]+ assert "ds:1" in str(excinfo.value)++ def test_total_failure_message_carries_the_consent_hint(self, no_backoff):+ client = _Sequence([self.BLANK])+ with pytest.raises(SearchClientError) as excinfo:+ _search_with(client).search(_filters(days=2))+ assert "consent/blocked page" in str(excinfo.value)++ def test_http_errors_are_not_retried(self, no_backoff):+ """Only a 200-with-no-payload is transient; a raised error is not."""+ client = StubClient(error=SearchConnectionError("connection refused"))+ with pytest.raises(SearchClientError):+ _search_with(client).search(_filters(days=1))+ assert client.calls == 1+ assert no_backoff == []+++# ---------------------------------------------------------------------------+# Per-date processing must be total (fix round 1, R5)+# ---------------------------------------------------------------------------+++class TestPerDateProcessingIsTotal:+ def test_zero_leg_row_with_a_window_does_not_sink_the_sweep(self):+ """A decoded row with no legs used to raise IndexError out of the sweep.++ ``_within_window`` reaches for ``legs[0]``; ``FlightResult.legs`` has+ no minimum length and Google's rows occasionally decode to none.+ """+ legless = _row(100.0)+ legless[0][2] = [] # detail[2] — the leg array+ client = StubClient(_page([legless, _row(500.0, hour=20)]))+ results = _search_with(client).search(+ _filters(+ days=2,+ time_restrictions=TimeRestrictions(earliest_departure=8, latest_departure=23),+ )+ )+ assert results is not None+ assert [r.price for r in results] == [500.0, 500.0]++ def test_failure_is_logged_without_a_traceback(self, caplog):+ """A 93-date sweep must not print 93 tracebacks; keep those at DEBUG."""+ client = StubClient(error=SearchConnectionError("connection refused"))+ with caplog.at_level(logging.WARNING, logger="fli.search.dates"):+ with pytest.raises(SearchClientError):+ _search_with(client).search(_filters(days=2))+ warnings = [r for r in caplog.records if r.levelno == logging.WARNING]+ assert warnings, "each bad date should still warn"+ assert all(r.exc_info is None for r in warnings), (+ "warnings must not carry exc_info — logging.lastResort prints the full traceback"+ )+ assert any("connection refused" in r.getMessage() for r in warnings)+++# ---------------------------------------------------------------------------+# Circuit breaker for a sweep that is failing deterministically (round 2, N4)+# ---------------------------------------------------------------------------+++class TestSweepCircuitBreaker:+ """A consent-blocked client fails identically on every date.++ `fetch_payload`'s retry and the client's own tenacity retries multiply, so+ paying three page fetches per date for a certain failure costs hundreds of+ requests to learn one thing. Once enough dates have come back payload-less+ and none has succeeded, stop.+ """++ BLANK = "<html>no data callback here</html>"++ @staticmethod+ def _ceiling() -> int:+ """Most fetches a fully blocked sweep can cost, whatever its length.++ The breaker trips after ``SWEEP_FAILURE_THRESHOLD`` failures, and every+ date already in flight at that moment still finishes its own retries —+ so the bound is (threshold + pool size) x attempts per page, with no+ term for the number of dates requested.+ """+ workers = get_executor()._max_workers+ return (dates_module.SWEEP_FAILURE_THRESHOLD + workers) * tfs_module.PAGE_FETCH_ATTEMPTS++ def test_always_blank_sweep_stops_early(self, no_backoff):+ client = StubClient(self.BLANK)+ with pytest.raises(SearchParseError) as excinfo:+ _search_with(client).search(_filters(days=30))++ # Without the breaker this is 30 dates x 3 attempts = 90 fetches.+ assert client.calls < 90, "the breaker did not stop the sweep"+ assert client.calls <= self._ceiling(), f"stopped, but late: {client.calls} fetches"+ message = str(excinfo.value)+ assert "consent/blocked page" in message+ assert "FLI_SOCS_COOKIE" in message++ def test_breaker_does_not_trip_once_any_date_succeeds(self, no_backoff):+ """A healthy first date means later misses are transient, not systemic."""+ good = _page([_row(150.0)])+ blank = self.BLANK++ class _FirstOneWorks(StubClient):+ def get(self, url: str, **kwargs: Any) -> _Response:+ with self._lock:+ self.calls += 1+ n = self.calls+ return _Response(good if n == 1 else blank)++ client = _FirstOneWorks()+ results = _search_with(client).search(_filters(days=12))++ # One date priced; every other date still got its full retry budget.+ assert results is not None and len(results) == 1+ assert client.calls == 1 + (12 - 1) * tfs_module.PAGE_FETCH_ATTEMPTS++ def test_healthy_sweep_is_unaffected(self, no_backoff):+ client = StubClient(_page([_row(150.0)]))+ results = _search_with(client).search(_filters(days=20))+ assert results is not None and len(results) == 20+ assert client.calls == 20++ def test_scattered_misses_below_the_threshold_do_not_trip(self, no_backoff):+ """Fewer payload-less dates than the threshold must all be retried."""+ good = _page([_row(150.0)])+ blank = self.BLANK+ misses = dates_module.SWEEP_FAILURE_THRESHOLD - 1++ class _FewMisses(StubClient):+ def __init__(self):+ super().__init__()+ self.seen: set[str] = set()++ def get(self, url: str, **kwargs: Any) -> _Response:+ with self._lock:+ self.calls += 1+ self.seen.add(url)+ bad = len(self.seen) <= misses+ return _Response(blank if bad else good)++ client = _FewMisses()+ results = _search_with(client).search(_filters(days=10))+ assert results is not None and len(results) == 10 - misses+ assert client.calls == misses * tfs_module.PAGE_FETCH_ATTEMPTS + (10 - misses)++ def test_generic_exceptions_do_not_trip_the_breaker(self, no_backoff):+ """Only the payload-less page is deterministic; a network blip is not.++ A blocked client fails identically on every date, which is what makes+ abandoning the sweep safe. A burst of connection errors says nothing+ about the dates that have not been tried yet, so counting those toward+ the threshold would abort a healthy sweep over a transient wobble.+ """+ good = _page([_row(150.0)])+ failures = dates_module.SWEEP_FAILURE_THRESHOLD++ class _EarlyBlips(StubClient):+ def get(self, url: str, **kwargs: Any) -> _Response:+ with self._lock:+ self.calls += 1+ n = self.calls+ if n <= failures:+ raise SearchConnectionError("connection refused")+ return _Response(good)++ client = _EarlyBlips()+ results = _search_with(client).search(_filters(days=20))++ # Nothing aborted: the five blips cost their own dates, everything else+ # priced normally.+ assert results is not None+ assert len(results) == 20 - failures+ assert client.calls == 20++ def test_a_wholly_dead_network_still_raises_at_the_end(self, no_backoff):+ """Not tripping is not the same as going quiet — the sweep still errors."""+ client = StubClient(error=SearchConnectionError("connection refused"))+ with pytest.raises(SearchClientError) as excinfo:+ _search_with(client).search(_filters(days=8))+ assert "every date in the range failed" in str(excinfo.value)+ # Every date was tried, because nothing here is known to be deterministic.+ assert client.calls == 8++ def test_tripped_sweep_that_still_returns_prices_warns_once(self, caplog):+ """A truncated answer must never be silent — that is this PR's whole point.++ Driven through ``_collect`` directly rather than through a sweep: after+ P1 the only way a success lands *after* a trip is a real race between+ worker threads, which cannot be staged deterministically. The contract+ being pinned is ``_collect``'s, so this exercises it head-on.+ """+ priced = dates_module.DatePrice(date=(FIRST_DAY,), price=150.0, currency="USD")+ outcomes = [+ dates_module._DateOutcome(price=priced),+ *[dates_module._DateOutcome(failure="the search page carried no ds:1 payload")] * 5,+ *[dates_module._DateOutcome(attempted=False)] * 24,+ ]++ with caplog.at_level(logging.WARNING, logger="fli.search.dates"):+ results = dates_module.SearchDates._collect(outcomes, 30, skipped=24)++ assert results == [priced]+ warnings = [r for r in caplog.records if r.levelno == logging.WARNING]+ assert len(warnings) == 1, f"expected exactly one warning, got {len(warnings)}"+ message = warnings[0].getMessage()+ assert "1 of 30" in message, message+ assert "24 were skipped" in message, message+ assert "FLI_SOCS_COOKIE" in message, message+ assert warnings[0].exc_info is None, "no traceback on the truncation warning"+ assert "\n" not in message, "the warning must be a single line"++ def test_tripped_sweep_with_no_prices_reports_once_as_an_error(self, caplog):+ """Nothing priced is already an exception; don't also warn about truncation."""+ outcomes = [+ *[dates_module._DateOutcome(failure=dates_module._NO_PAYLOAD)] * 5,+ *[dates_module._DateOutcome(attempted=False)] * 25,+ ]+ with caplog.at_level(logging.WARNING, logger="fli.search.dates"):+ with pytest.raises(SearchParseError):+ dates_module.SearchDates._collect(outcomes, 30, skipped=25)+ assert not [r for r in caplog.records if "skipped" in r.getMessage()]++ def test_tripped_sweep_with_no_prices_never_ends_quietly(self, caplog):+ """Tripped + a date that loaded but had no flights + nothing priced.++ The truncation warning was guarded on there being prices, and the+ "everything failed" error needs *every* attempted date to have failed —+ so a single loaded-but-empty date fell between the two and the sweep+ returned ``None`` with 24 dates abandoned and not a word about it.+ With no prices at all this is a blocked sweep, so it raises.+ """+ outcomes = [+ dates_module._DateOutcome(), # page loaded fine, route has no flights+ *[dates_module._DateOutcome(failure=dates_module._NO_PAYLOAD)] * 5,+ *[dates_module._DateOutcome(attempted=False)] * 24,+ ]+ with caplog.at_level(logging.WARNING, logger="fli.search.dates"):+ with pytest.raises(SearchParseError) as excinfo:+ dates_module.SearchDates._collect(outcomes, 30, skipped=24)+ message = str(excinfo.value)+ assert "24 skipped" in message, message+ assert "FLI_SOCS_COOKIE" in message, message+ assert "consent/blocked page" in message, message++ def test_tripped_breaker_always_gives_the_blocked_page_error(self):+ """Blank pages interleaved with connection errors is still a blocked sweep.++ The hint used to be all-or-nothing: one connection error alongside the+ blank pages downgraded the error to `SearchClientError` and dropped the+ `FLI_SOCS_COOKIE` pointer — even though the breaker only ever trips on+ blank pages, so a trip means the blocked page is the dominant cause.+ """+ outcomes = [+ *[dates_module._DateOutcome(failure=dates_module._NO_PAYLOAD)] * 5,+ *[+ dates_module._DateOutcome(+ failure="SearchConnectionError: connection refused",+ error=SearchConnectionError("connection refused"),+ )+ ]+ * 4,+ *[dates_module._DateOutcome(attempted=False)] * 21,+ ]+ with pytest.raises(SearchParseError) as excinfo:+ dates_module.SearchDates._collect(outcomes, 30, skipped=21)+ message = str(excinfo.value)+ assert "FLI_SOCS_COOKIE" in message, message+ # Both causes are still reported, not just the dominant one.+ assert "ds:1" in message and "connection refused" in message, message++ def test_untripped_mixed_failures_keep_the_general_error(self):+ """Without a trip the error type still follows what actually failed."""+ outcomes = [+ dates_module._DateOutcome(failure=dates_module._NO_PAYLOAD),+ dates_module._DateOutcome(+ failure="SearchConnectionError: connection refused",+ error=SearchConnectionError("connection refused"),+ ),+ ]+ with pytest.raises(SearchClientError) as excinfo:+ dates_module.SearchDates._collect(outcomes, 2)+ assert not isinstance(excinfo.value, SearchParseError)+ assert "FLI_SOCS_COOKIE" not in str(excinfo.value)++ def test_untripped_sweep_does_not_warn_about_truncation(self, no_backoff, caplog):+ """A healthy sweep prices every date, so there is nothing to announce."""+ client = StubClient(_page([_row(150.0)]))+ with caplog.at_level(logging.WARNING, logger="fli.search.dates"):+ results = _search_with(client).search(_filters(days=12))+ assert results is not None and len(results) == 12+ assert not [r for r in caplog.records if "skipped" in r.getMessage()]++ @pytest.mark.parametrize("days", [30, 61, 93])+ def test_blocked_sweep_costs_the_same_at_any_range(self, days, no_backoff):+ """The cost of learning "this client is blocked" must not scale with the range.++ Before the breaker it was 3 fetches per date — 279 for a quarter, and+ up to 837 once the client's own three retries multiplied in.+ """+ client = StubClient(self.BLANK)+ with pytest.raises(SearchParseError):+ _search_with(client).search(_filters(days=days))+ assert client.calls <= self._ceiling(), (+ f"{days}-date blocked sweep cost {client.calls} fetches"+ )++ def test_error_says_it_gave_up_early(self, no_backoff):+ client = StubClient(self.BLANK)+ with pytest.raises(SearchParseError) as excinfo:+ _search_with(client).search(_filters(days=40))+ assert "of 40 dates" in str(excinfo.value)diff --git a/tests/search/test_parallel_search.py b/tests/search/test_parallel_search.pyindex 9ae6741..29294ce 100644--- a/tests/search/test_parallel_search.py+++ b/tests/search/test_parallel_search.py@@ -9,7 +9,6 @@ total request count matches what the search code is expected to issue.from __future__ import annotations-import jsonimport threadingimport timefrom copy import deepcopy@@ -32,6 +31,8 @@ from fli.models import (TripType,)from fli.search import SearchDates, SearchFlights+from fli.search._wire import iter_wrb_chunks+from tests.search._pages import as_search_pageFIXTURE_DIR = Path(__file__).parent / "fixtures"@@ -84,19 +85,20 @@ class FakeClient:return self._do()-def _date_fixture(days: int = 61) -> str:- """Minimal ``GetCalendarGraph`` body for the date-search parser."""- base = datetime(2026, 7, 1)- entries = [- [- (base + timedelta(days=i)).strftime("%Y-%m-%d"),- None,- [[None, 200.0 + i], "USD0.000"],- ]- for i in range(days)- ]- inner = json.dumps([None, None, entries])- return ")]}'\n" + json.dumps([["wrb.fr", None, inner]])+# Segment travel dates are validated against today, so keep the fixtures+# relative — hardcoded dates rot the suite the moment they go past.+DEPART = datetime.now().replace(hour=0, minute=0, second=0, microsecond=0) + timedelta(days=30)+RETURN = DEPART + timedelta(days=7)+++def _page_fixture(name: str = "flight_search_jfk_lax_oneway_usd") -> str:+ """Re-serve a captured response as the search page the client now reads.++ The page's ``ds:1`` payload carries the flight rows at the same+ positions the RPC body used, so the captured fixtures stay usable.+ """+ raw = (FIXTURE_DIR / f"{name}.bin").read_text()+ return as_search_page(next(iter_wrb_chunks(raw)))# ---------------------------------------------------------------------------@@ -112,12 +114,12 @@ def _round_trip_filters() -> FlightSearchFilters:FlightSegment(departure_airport=[[Airport.JFK, 0]],arrival_airport=[[Airport.LAX, 0]],- travel_date="2026-08-01",+ travel_date=DEPART.strftime("%Y-%m-%d"),),FlightSegment(departure_airport=[[Airport.LAX, 0]],arrival_airport=[[Airport.JFK, 0]],- travel_date="2026-08-08",+ travel_date=RETURN.strftime("%Y-%m-%d"),),],)@@ -131,11 +133,11 @@ def _date_filters(days: int) -> DateSearchFilters:FlightSegment(departure_airport=[[Airport.JFK, 0]],arrival_airport=[[Airport.LAX, 0]],- travel_date="2026-08-01",+ travel_date=DEPART.strftime("%Y-%m-%d"),)],- from_date="2026-08-01",- to_date=(datetime(2026, 8, 1) + timedelta(days=days - 1)).strftime("%Y-%m-%d"),+ from_date=DEPART.strftime("%Y-%m-%d"),+ to_date=(DEPART + timedelta(days=days - 1)).strftime("%Y-%m-%d"),)@@ -149,7 +151,7 @@ class TestRoundTripParallel:@pytest.fixturedef fixture_text(self) -> str:- return (FIXTURE_DIR / "flight_search_jfk_lax_oneway_usd.bin").read_text()+ return _page_fixture()def test_peak_in_flight_matches_top_n(self, fixture_text):fake = FakeClient(fixture_text, latency_ms=60.0)@@ -205,8 +207,8 @@ class TestRoundTripParallel:flight_number=tag,departure_airport=Airport.JFK,arrival_airport=Airport.LAX,- departure_datetime=datetime(2026, 7, 15, 9, 0),- arrival_datetime=datetime(2026, 7, 15, 12, 0),+ departure_datetime=DEPART.replace(hour=9),+ arrival_datetime=DEPART.replace(hour=12),duration=180,)],@@ -256,31 +258,33 @@ class TestRoundTripParallel:class TestDateChunkParallel:- def test_three_chunks_overlap(self):- fake = FakeClient(_date_fixture(days=61), latency_ms=60.0)+ # The page transport has no calendar grid, so a date sweep costs one+ # page fetch per date rather than one per 61-day chunk.+ def test_every_date_priced_in_parallel(self):+ fake = FakeClient(_page_fixture(), latency_ms=10.0)search = SearchDates()search.client = fake- # 180 days / 61 = 3 chunks.- results = search.search(_date_filters(days=180))+ # 93 days is the per-search cap (see fli.search.dates) and spans two+ # 61-day chunks; every date is priced by its own concurrent fetch.+ results = search.search(_date_filters(days=93))- assert results is not None and len(results) > 0- assert fake.calls == 3+ assert results is not None and len(results) == 93+ assert fake.calls == 93assert fake.peak_in_flight >= 2, (- f"Date chunks did not parallelise (peak={fake.peak_in_flight})"+ f"Date pricing did not parallelise (peak={fake.peak_in_flight})")- def test_single_chunk_skips_executor(self):- """Sub-61-day ranges still take the synchronous fast path."""- fake = FakeClient(_date_fixture(days=30), latency_ms=10.0)+ def test_single_chunk_still_prices_each_date(self):+ """Sub-61-day ranges skip the chunk split but still price per date."""+ fake = FakeClient(_page_fixture(), latency_ms=10.0)search = SearchDates()search.client = fakeresults = search.search(_date_filters(days=30))- assert results is not None- assert fake.calls == 1- assert fake.peak_in_flight == 1+ assert results is not None and len(results) == 30+ assert fake.calls == 30def test_chunk_filters_advance_segment_dates(self):"""Each chunk's segment ``travel_date`` is offset by N×61 days."""@@ -295,7 +299,7 @@ class TestDateChunkParallel:first = chunks[0].flight_segments[0].travel_datesecond = chunks[1].flight_segments[0].travel_datethird = chunks[2].flight_segments[0].travel_date- assert first == "2026-08-01"+ assert first == DEPART.strftime("%Y-%m-%d")# Shifted by exactly 61 and 122 days.assert datetime.strptime(second, "%Y-%m-%d") - datetime.strptime(first, "%Y-%m-%d"diff --git a/tests/search/test_search_dates.py b/tests/search/test_search_dates.pyindex db91911..4420bfc 100644--- a/tests/search/test_search_dates.py+++ b/tests/search/test_search_dates.py@@ -147,11 +147,45 @@ def complex_round_trip_params():)+# Infant searches themselves work: the ``tfs`` passenger codes are verified+# against Google's own pricing (1=adult, 2=child, 3=lap infant, 4=infant in+# seat — see TestPassengerCodes in test_tfs.py and TestLapInfantPricing in+# test_search_flights_new_filters_live.py), and JFK->LHR economy with a lap+# infant returns 15 rows.+#+# What still comes back empty is this particular combination. Probed live+# 2026-09-20, one-stop-or-fewer, 60 days out:+#+# 2a+1c FIRST JFK->LAX 22 rows+# 1a ECONOMY JFK->LAX 35 rows+# 1a FIRST JFK->LHR 10 rows+# 2a+1c+1lap FIRST JFK->LAX 0 rows <- this fixture+# 2a+1c+1lap ECONOMY JFK->LAX 0 rows+# 2a+1c+1seat ECONOMY JFK->LAX 0 rows+# 2a+1c+1lap ECONOMY JFK->LHR 15 rows+# 2a+1c+1lap FIRST JFK->LHR 0 rows+#+# So any infant on JFK->LAX, and any lap infant in FIRST, yields a page with+# no results grid, while the same passenger mix on other route/cabin pairs is+# served normally. Nothing in the request is rejected — Google simply inlines+# no rows — which reads as inventory rather than encoding. Non-strict so a+# change on Google's side surfaces as an unexpected pass.+INFANT_RESULTS_MISSING = pytest.mark.xfail(+ reason=(+ "Google inlines no results for JFK-LAX / LAX-ORD with a lap infant in "+ "FIRST or BUSINESS (0 rows); the same query without the infant returns "+ "22, and JFK-LHR economy with the same lap infant returns 15 — so the "+ "tfs passenger codes are correct and this is Google-side"+ ),+ strict=False,+)++@pytest.mark.parametrize("search_params_fixture",["basic_search_params",- "complex_search_params",+ pytest.param("complex_search_params", marks=INFANT_RESULTS_MISSING),],)def test_search_functionality(search, search_params_fixture, request):@@ -161,6 +195,7 @@ def test_search_functionality(search, search_params_fixture, request):assert isinstance(results, list)+@INFANT_RESULTS_MISSINGdef test_multiple_searches(search, basic_search_params, complex_search_params):"""Test performing multiple searches with the same SearchDates instance."""# First search@@ -271,3 +306,48 @@ def test_round_trip_result_structure(search, search_params_fixture, request):assert outbound_date <= return_date # Return can be same day or laterassert hasattr(result, "price")assert result.price > 0+++class TestRoundTripDurationFallback:+ """A round trip with no explicit ``duration`` still prices a return leg.++ ``DateSearchFilters.duration`` is optional and its validator doesn't run+ on the default, so round-trip filters can reach the search with it unset.+ The return date then comes from the gap between the two segments.+ """++ def test_return_date_derived_from_segments(self, monkeypatch, round_trip_search_params):+ import base64+ from pathlib import Path++ from fli.search._wire import iter_wrb_chunks+ from tests.search._pages import as_search_page++ assert round_trip_search_params.duration is None+ page = as_search_page(+ next(+ iter_wrb_chunks(+ (+ Path(__file__).parent / "fixtures" / "flight_search_jfk_lax_oneway_usd.bin"+ ).read_text()+ )+ )+ )+ urls: list[str] = []++ def _fake_get(url, **kwargs):+ urls.append(url)+ return type("R", (), {"text": page, "raise_for_status": lambda s: None})()++ search = SearchDates()+ monkeypatch.setattr(search.client, "get", _fake_get)+ results = search.search(round_trip_search_params)++ assert results and all(len(r.date) == 2 for r in results)+ # Outbound and return are 7 days apart in the fixture's segments.+ assert all((r.date[1] - r.date[0]).days == 7 for r in results)+ tfs = urls[0].split("tfs=")[1].split("&")[0]+ decoded = base64.urlsafe_b64decode(tfs + "=" * (-len(tfs) % 4)).decode("latin-1")+ for r in results[:1]:+ assert r.date[0].strftime("%Y-%m-%d") in decoded+ assert r.date[1].strftime("%Y-%m-%d") in decodeddiff --git a/tests/search/test_search_flights.py b/tests/search/test_search_flights.pyindex d12852c..917fc59 100644--- a/tests/search/test_search_flights.py+++ b/tests/search/test_search_flights.py@@ -153,11 +153,45 @@ def complex_round_trip_params():)+# Infant searches themselves work: the ``tfs`` passenger codes are verified+# against Google's own pricing (1=adult, 2=child, 3=lap infant, 4=infant in+# seat — see TestPassengerCodes in test_tfs.py and TestLapInfantPricing in+# test_search_flights_new_filters_live.py), and JFK->LHR economy with a lap+# infant returns 15 rows.+#+# What still comes back empty is this particular combination. Probed live+# 2026-09-20, one-stop-or-fewer, 60 days out:+#+# 2a+1c FIRST JFK->LAX 22 rows+# 1a ECONOMY JFK->LAX 35 rows+# 1a FIRST JFK->LHR 10 rows+# 2a+1c+1lap FIRST JFK->LAX 0 rows <- this fixture+# 2a+1c+1lap ECONOMY JFK->LAX 0 rows+# 2a+1c+1seat ECONOMY JFK->LAX 0 rows+# 2a+1c+1lap ECONOMY JFK->LHR 15 rows+# 2a+1c+1lap FIRST JFK->LHR 0 rows+#+# So any infant on JFK->LAX, and any lap infant in FIRST, yields a page with+# no results grid, while the same passenger mix on other route/cabin pairs is+# served normally. Nothing in the request is rejected — Google simply inlines+# no rows — which reads as inventory rather than encoding. Non-strict so a+# change on Google's side surfaces as an unexpected pass.+INFANT_RESULTS_MISSING = pytest.mark.xfail(+ reason=(+ "Google inlines no results for JFK-LAX / LAX-ORD with a lap infant in "+ "FIRST or BUSINESS (0 rows); the same query without the infant returns "+ "22, and JFK-LHR economy with the same lap infant returns 15 — so the "+ "tfs passenger codes are correct and this is Google-side"+ ),+ strict=False,+)++@pytest.mark.parametrize("search_params_fixture",["basic_search_params",- "complex_search_params",+ pytest.param("complex_search_params", marks=INFANT_RESULTS_MISSING),],)def test_search_functionality(search, search_params_fixture, request):@@ -167,6 +201,7 @@ def test_search_functionality(search, search_params_fixture, request):assert isinstance(results, list)+@INFANT_RESULTS_MISSINGdef test_multiple_searches(search, basic_search_params, complex_search_params):"""Test performing multiple searches with the same Search instance."""# First search@@ -268,12 +303,13 @@ class TestParsePriceInfo:class TestSearchParseErrorMessage:"""SearchParseError surfaces sample reasons when every row fails."""- def _client_with_canned_response(self, body: str) -> SearchFlights:- from unittest.mock import patch-+ def _client_with_canned_response(self, monkeypatch, body: str) -> SearchFlights:+ # ``sf.client`` is the process-wide singleton, so the patch must be+ # undone when the test ends — ``monkeypatch`` does that for us.+ # A leaked patch here feeds this canned body to every later test.sf = SearchFlights()- def _fake_post(url, data, **kwargs): # noqa: ANN001+ def _fake_get(url, **kwargs): # noqa: ANN001return type("R",(),@@ -284,28 +320,30 @@ class TestSearchParseErrorMessage:},)()- patcher = patch.object(sf.client, "post", side_effect=_fake_post)- patcher.start()+ monkeypatch.setattr(sf.client, "get", _fake_get)return sfdef _build_response(self, rows: list) -> str:- """Wrap ``rows`` in a minimal but parser-valid wrb.fr response."""+ """Wrap ``rows`` in a minimal but parser-valid search page."""import json- # ``_capture_session_id`` reads ``inner[0][4]`` — give it a+ # ``_capture_session_id`` reads ``payload[0][4]`` — give it a# plausible 5-element list. ``_fetch_flights`` reads- # ``inner[2]`` and ``inner[3]`` — index 3 must exist (any list+ # ``payload[2]`` and ``payload[3]`` — index 3 must exist (any list# value is fine; we put the rows on index 2).- inner = [+ payload = [[None, None, None, None, "FAKE_SESSION"],None,[[*rows]],None,]- outer = [["wrb.fr", None, json.dumps(inner, separators=(",", ":"))]]- return ")]}'\n\n" + json.dumps(outer)+ return (+ "<script>AF_initDataCallback({key: 'ds:1', hash: '1', data:"+ + json.dumps(payload, separators=(",", ":"))+ + ", sideChannel: {}});</script>"+ )- def test_error_includes_sample_failure_reasons(self):+ def test_error_includes_sample_failure_reasons(self, monkeypatch):"""When all rows fail, the error message names what went wrong."""from fli.search.flights import SearchParseError@@ -314,7 +352,7 @@ class TestSearchParseErrorMessage:bad_row = [None, [[None, "not-a-number"]]]body = self._build_response([bad_row, bad_row, bad_row])- sf = self._client_with_canned_response(body)+ sf = self._client_with_canned_response(monkeypatch, body)filters = FlightSearchFilters(passenger_info=PassengerInfo(adults=1),flight_segments=[@@ -328,13 +366,13 @@ class TestSearchParseErrorMessage:with pytest.raises(SearchParseError, match="sample reasons:.*not numeric"):sf.search(filters)- def test_error_dedups_repeated_reasons(self):+ def test_error_dedups_repeated_reasons(self, monkeypatch):"""Identical failure messages collapse to a single sample."""from fli.search.flights import SearchParseErrorbad_row = [None, [[None, "not-a-number"]]]body = self._build_response([bad_row] * 10)- sf = self._client_with_canned_response(body)+ sf = self._client_with_canned_response(monkeypatch, body)filters = FlightSearchFilters(passenger_info=PassengerInfo(adults=1),flight_segments=[@@ -351,3 +389,83 @@ class TestSearchParseErrorMessage:msg = str(excinfo.value)assert msg.count("not numeric") == 1assert "0/10" in msg+++class TestTransientPageRetryOnFlightSearch:+ """Roughly one page in 60 arrives HTTP 200 with no ``ds:1`` blob.++ A round trip fetches six pages, so the per-search failure rate compounds.+ The retry lives in the shared page-fetch helper, so this exercises the same+ code path the date sweep uses.+ """++ BLANK = "<html>no data callback here</html>"++ @staticmethod+ def _filters() -> FlightSearchFilters:+ return FlightSearchFilters(+ passenger_info=PassengerInfo(adults=1),+ flight_segments=[+ FlightSegment(+ departure_airport=[[Airport.JFK, 0]],+ arrival_airport=[[Airport.LAX, 0]],+ travel_date=(datetime.now() + timedelta(days=30)).strftime("%Y-%m-%d"),+ )+ ],+ )++ @staticmethod+ def _good_page() -> str:+ import json++ from tests.search.test_parse_flights_data import _leg, _row++ payload = [+ [None, None, None, None, "FAKE_SESSION"],+ None,+ [[_row(legs=[_leg(dep_iata="JFK", arr_iata="LAX")])]],+ None,+ ]+ return (+ "<script>AF_initDataCallback({key: 'ds:1', hash: '1', data:"+ + json.dumps(payload, separators=(",", ":"))+ + ", sideChannel: {}});</script>"+ )++ def _sequenced(self, monkeypatch, bodies: list[str]):+ from fli.search import _tfs as tfs_module++ calls: list[str] = []+ slept: list[float] = []+ monkeypatch.setattr(tfs_module, "_sleep", slept.append)++ sf = SearchFlights()++ def _fake_get(url, **kwargs): # noqa: ANN001+ body = bodies[min(len(calls), len(bodies) - 1)]+ calls.append(url)+ return type("R", (), {"text": body, "raise_for_status": lambda self: None})()++ monkeypatch.setattr(sf.client, "get", _fake_get)+ return sf, calls, slept++ def test_healthy_page_is_fetched_once(self, monkeypatch):+ sf, calls, slept = self._sequenced(monkeypatch, [self._good_page()])+ assert sf.search(self._filters())+ assert len(calls) == 1+ assert slept == []++ def test_missing_once_then_present_succeeds_in_two_fetches(self, monkeypatch):+ sf, calls, slept = self._sequenced(monkeypatch, [self.BLANK, self._good_page()])+ assert sf.search(self._filters())+ assert len(calls) == 2+ assert slept == [0.5]++ def test_missing_three_times_raises_after_exactly_three_fetches(self, monkeypatch):+ from fli.search.flights import SearchParseError++ sf, calls, slept = self._sequenced(monkeypatch, [self.BLANK])+ with pytest.raises(SearchParseError, match="no ds:1 payload"):+ sf.search(self._filters())+ assert len(calls) == 3+ assert slept == [0.5, 1.5]diff --git a/tests/search/test_search_flights_new_filters_live.py b/tests/search/test_search_flights_new_filters_live.pyindex 6bee151..1086e00 100644--- a/tests/search/test_search_flights_new_filters_live.py+++ b/tests/search/test_search_flights_new_filters_live.py@@ -267,6 +267,14 @@ class TestBookingOptionsAutoSession:cached session — no `tfu` URL extraction, no browser involvement."""+ # ``GetBookingResults`` is still an RPC endpoint, so it still needs the+ # browser-signed ``x-goog-batchexecute-bgr`` header this client cannot+ # produce (#223) and answers with error 13. The search-page transport+ # does not cover it. Non-strict so the test reports a pass the day+ # booking options come back.+ @pytest.mark.xfail(+ reason="GetBookingResults still requires the bgr header (#223)", strict=False+ )def test_round_trip_zero_friction_booking_options(self, client):filters = FlightSearchFilters(trip_type=TripType.ROUND_TRIP,@@ -338,3 +346,51 @@ class TestRichResponseFields:if f.booking_token:returnpytest.fail("Expected at least one result with booking_token set")+++class TestLapInfantPricing:+ """Google must read our lap-infant passenger code as a lap infant.++ ``tfs`` field 8 numbers passengers 1=adult, 2=child, 3=infant on lap,+ 4=infant in own seat. The two infant codes were transposed, which does not+ error: Google prices a lap infant like a seat infant, roughly doubling the+ quoted fare on an international route instead of adding ~10%.++ Unit tests pin the bytes we emit; only a live call can confirm Google reads+ them the way we think. Asserting a ratio rather than a price keeps this+ durable against fare movement.+ """++ ROUTE = (Airport.JFK, Airport.LHR)++ def _cheapest_common_flight(self, client, passengers: PassengerInfo):+ filters = FlightSearchFilters(+ trip_type=TripType.ONE_WAY,+ passenger_info=passengers,+ flight_segments=_segments(*self.ROUTE),+ airlines=[Airline.BA],+ )+ results = client.search(filters, currency="USD")+ return {+ f.legs[0].flight_number: f.price+ for f in (results or [])+ if len(f.legs) == 1 and f.price+ }++ def test_lap_infant_adds_about_ten_percent_not_a_second_fare(self, client):+ adult_only = self._cheapest_common_flight(client, PassengerInfo(adults=1))+ with_infant = self._cheapest_common_flight(+ client, PassengerInfo(adults=1, infants_on_lap=1)+ )+ shared = sorted(set(adult_only) & set(with_infant))+ if not shared:+ pytest.skip("no non-stop BA itinerary priced in both searches right now")++ number = shared[0]+ ratio = with_infant[number] / adult_only[number]+ # A lap infant is a fraction of the adult fare; the transposed code+ # priced a second seat, landing near 2.0x.+ assert 1.0 <= ratio < 1.5, (+ f"BA{number}: {adult_only[number]} -> {with_infant[number]} ({ratio:.2f}x) — "+ "a lap infant should add roughly 10%, not a second fare"+ )diff --git a/tests/search/test_snapshot_fixtures.py b/tests/search/test_snapshot_fixtures.pyindex 4d4a7f7..73f526a 100644--- a/tests/search/test_snapshot_fixtures.py+++ b/tests/search/test_snapshot_fixtures.py@@ -321,3 +321,53 @@ class TestPremiumRoundTripPriceless:assert f.duration > 0assert f.legs[0].departure_airport.name == "LAX"assert f.legs[-1].arrival_airport.name == "LHR"+++class TestRealSearchPageExtraction:+ """`extract_payload` against a real captured search page.++ Every other fixture here is an RPC body; this one is the page HTML the+ transport actually reads now, so it is the only offline guard on the+ regex that finds the ``ds:1`` blob among the page's other+ ``AF_initDataCallback`` blocks. The file keeps that script block exactly+ as Google served it, inside a minimal HTML shell.++ Same drift policy as the rest of the module: assert structure, never+ prices or flight numbers.+ """++ FIXTURE = "search_page_jfk_lhr_nonstop_ds1.html"++ @pytest.fixture(scope="class")+ def page(self) -> str:+ return (FIXTURE_DIR / self.FIXTURE).read_text(encoding="utf-8")++ def test_payload_is_extracted(self, page):+ from fli.search._tfs import extract_payload++ payload = extract_payload(page)+ assert isinstance(payload, list) and len(payload) > 3++ def test_payload_decodes_into_flights(self, page):+ from fli.search._tfs import extract_payload++ payload = extract_payload(page)+ flights = []+ for index in (2, 3):+ block = payload[index] if index < len(payload) else None+ if not isinstance(block, list) or not block:+ continue+ for row in block[0]:+ try:+ flights.append(parse_flight_row(row))+ except (AttributeError, IndexError, KeyError, TypeError, ValueError):+ continue+ assert len(flights) > 0, "a real search page must decode into at least one flight"+ assert all(f.legs for f in flights)+ assert {f.legs[0].departure_airport.name for f in flights} == {"JFK"}++ def test_fixture_carries_no_cookies(self, page):+ """The capture must not ship anything account-specific."""+ lowered = page.lower()+ for marker in ("set-cookie", "sapisid", "apisid", "hsid", "__secure-", "authuser"):+ assert marker not in lowered, f"fixture leaks {marker!r}"diff --git a/tests/search/test_tfs.py b/tests/search/test_tfs.pynew file mode 100644index 0000000..acf8d58--- /dev/null+++ b/tests/search/test_tfs.py@@ -0,0 +1,556 @@+"""Tests for the search-page transport (``fli.search._tfs``).++The ``tfs`` fixtures below were issued by Google itself for the same queries,+so a byte mismatch means the encoder has drifted from what Google accepts.+Everything here is offline — no live API calls.+"""++from __future__ import annotations++from datetime import datetime++import pytest++from fli.models import (+ Airline,+ Airport,+ Alliance,+ FlightLeg,+ FlightResult,+ FlightSearchFilters,+ FlightSegment,+ LayoverRestrictions,+ MaxStops,+ PassengerInfo,+ PriceLimit,+ SeatType,+ TimeRestrictions,+ TripType,+)+from fli.search._tfs import (+ apply_client_side_filters,+ build_tfs,+ extract_payload,+ page_url,+ unsupported_filters,+)+from fli.search.exceptions import SearchUnsupportedError++# Captured from Google's own search-page URLs (2026-08-26) for+# JFK -> LAX on 2026-09-15, returning 2026-09-19.+TFS_ONE_WAY = "CBwQAhoeEgoyMDI2LTA5LTE1agcIARIDSkZLcgcIARIDTEFYQAFIAXABmAEC"+TFS_NON_STOP = "CBwQAhogEgoyMDI2LTA5LTE1KABqBwgBEgNKRktyBwgBEgNMQVhAAUgBcAGYAQI"+TFS_ROUND_TRIP = (+ "CBwQAhoeEgoyMDI2LTA5LTE1agcIARIDSkZLcgcIARIDTEFYGh4SCjIwMjYtMDktMTlqBwgBEgNMQVhy"+ "BwgBEgNKRktAAUgBcAGYAQE"+)++TFS_MULTI_AIRPORT = (+ "CBwQAho5EgoyMDI2LTEwLTE1agcIARIDQk9NagcIARIDREVMagcIARIDQU1EcgcIARIDT1JEcgcIARIDRFRX"+ "QAFIAXABmAEC"+)++OUTBOUND_DATE = "2026-09-15"+RETURN_DATE = "2026-09-19"++# The travel dates above are part of the captured tokens, so they can't be+# made relative — but the filter models reject a date in the past, which+# would have made this whole module start failing on 2026-09-16. Pin the+# models' clock to the capture date instead, so the assertions hold on any+# calendar date the suite runs on.+CAPTURE_DATE = "2026-08-26"++[email protected](autouse=True)+def _pinned_clock(pin_today):+ """Freeze "today" at the date the ``tfs`` fixtures were captured."""+ pin_today(CAPTURE_DATE)+++def _filters(segments, **kwargs) -> FlightSearchFilters:+ """Build filters over ``(origin, destination, date)`` triples."""+ return FlightSearchFilters(+ trip_type=kwargs.get("trip_type", TripType.ONE_WAY),+ passenger_info=kwargs.get("passenger_info", PassengerInfo(adults=1)),+ flight_segments=[+ FlightSegment(+ departure_airport=[[Airport[origin], 0]],+ arrival_airport=[[Airport[destination], 0]],+ travel_date=date,+ time_restrictions=kwargs.get("time_restrictions"),+ )+ for origin, destination, date in segments+ ],+ stops=kwargs.get("stops", MaxStops.ANY),+ seat_type=kwargs.get("seat_type", SeatType.ECONOMY),+ airlines=kwargs.get("airlines"),+ airlines_exclude=kwargs.get("airlines_exclude"),+ max_duration=kwargs.get("max_duration"),+ price_limit=kwargs.get("price_limit"),+ )+++def _decode(tfs: str) -> bytes:+ """Decode a tfs value, restoring the padding Google's URLs strip."""+ import base64++ return base64.urlsafe_b64decode(tfs + "=" * (-len(tfs) % 4))+++def _passenger_codes(tfs: str) -> list[int]:+ """Read the repeated field 8 (passenger kinds) out of a ``tfs`` token.++ Walks the top-level message properly instead of scanning for the 0x40+ tag byte, which also occurs inside length-delimited payloads.+ """+ from fli.search._proto import _read_varint++ raw = _decode(tfs)+ codes: list[int] = []+ offset = 0+ while offset < len(raw):+ tag, offset = _read_varint(raw, offset)+ field, wire = tag >> 3, tag & 0x7+ if wire == 0:+ value, offset = _read_varint(raw, offset)+ if field == 8:+ codes.append(value)+ elif wire == 2:+ length, offset = _read_varint(raw, offset)+ offset += length+ else: # pragma: no cover - the encoder emits only wire types 0 and 2+ raise AssertionError(f"unexpected wire type {wire} at offset {offset}")+ return codes+++def _flight(+ airline: Airline = Airline.AA,+ price: float = 300,+ duration: int = 180,+ hour: int = 9,+) -> FlightResult:+ return FlightResult(+ legs=[+ FlightLeg(+ airline=airline,+ flight_number="171",+ departure_airport=Airport.JFK,+ arrival_airport=Airport.LAX,+ departure_datetime=datetime(2026, 9, 15, hour, 0),+ arrival_datetime=datetime(2026, 9, 15, hour + 3, 0),+ duration=duration,+ )+ ],+ price=price,+ currency="USD",+ duration=duration,+ stops=0,+ )+++class TestBuildTfs:+ def test_one_way_matches_google(self):+ assert build_tfs(_filters([("JFK", "LAX", OUTBOUND_DATE)])) == TFS_ONE_WAY++ def test_non_stop_matches_google(self):+ built = build_tfs(_filters([("JFK", "LAX", OUTBOUND_DATE)], stops=MaxStops.NON_STOP))+ assert built == TFS_NON_STOP++ def test_round_trip_matches_google(self):+ built = build_tfs(+ _filters(+ [("JFK", "LAX", OUTBOUND_DATE), ("LAX", "JFK", RETURN_DATE)],+ trip_type=TripType.ROUND_TRIP,+ )+ )+ assert built == TFS_ROUND_TRIP++ def test_any_stops_omits_the_ceiling(self):+ """MaxStops.ANY must leave field 5 out — writing 0 means non-stop."""+ assert build_tfs(_filters([("JFK", "LAX", OUTBOUND_DATE)])) != TFS_NON_STOP++ @pytest.mark.parametrize(+ ("stops", "expected_ceiling"),+ [+ (MaxStops.NON_STOP, 0),+ (MaxStops.ONE_STOP_OR_FEWER, 1),+ (MaxStops.TWO_OR_FEWER_STOPS, 2),+ ],+ )+ def test_stop_ceiling_is_zero_based(self, stops: MaxStops, expected_ceiling: int) -> None:+ raw = _decode(build_tfs(_filters([("JFK", "LAX", OUTBOUND_DATE)], stops=stops)))+ # Field 5, varint: tag 0x28 followed by the ceiling.+ assert bytes([0x28, expected_ceiling]) in raw++ def test_every_airport_reaches_the_request(self):+ """All origins and destinations must survive encoding.++ Serializing only entry zero still produces a valid, successful search+ for the first pair, so a truncated request looks like a working one and+ the missing city pairs never surface as an error.+ """+ spec = FlightSearchFilters(+ trip_type=TripType.ONE_WAY,+ passenger_info=PassengerInfo(adults=1),+ flight_segments=[+ FlightSegment(+ departure_airport=[[Airport.BOM, 0], [Airport.DEL, 0], [Airport.AMD, 0]],+ arrival_airport=[[Airport.ORD, 0], [Airport.DTW, 0]],+ travel_date=OUTBOUND_DATE,+ )+ ],+ stops=MaxStops.ANY,+ seat_type=SeatType.ECONOMY,+ )+ raw = _decode(build_tfs(spec))+ for code in (b"BOM", b"DEL", b"AMD", b"ORD", b"DTW"):+ assert code in raw, f"{code.decode()} was dropped from the request"++ def test_multi_airport_matches_google(self):+ """Byte-for-byte against a tfs Google issued for the same query."""+ spec = FlightSearchFilters(+ trip_type=TripType.ONE_WAY,+ passenger_info=PassengerInfo(adults=1),+ flight_segments=[+ FlightSegment(+ departure_airport=[[Airport.BOM, 0], [Airport.DEL, 0], [Airport.AMD, 0]],+ arrival_airport=[[Airport.ORD, 0], [Airport.DTW, 0]],+ travel_date="2026-10-15",+ )+ ],+ stops=MaxStops.ANY,+ seat_type=SeatType.ECONOMY,+ )+ assert build_tfs(spec) == TFS_MULTI_AIRPORT++ def test_travel_dates_override_segment_dates(self):+ spec = _filters([("JFK", "LAX", OUTBOUND_DATE)])+ assert build_tfs(spec, travel_dates=["2026-10-01"]) != build_tfs(spec)++ def test_selected_flight_uses_field_four(self):+ """Legs pin the search only in field 4.++ Google ignores an unknown field number and silently re-serves the+ outbound board, so a wrong slot here makes round-trip expansion pair+ outbound flights with other outbound flights without erroring.+ """+ spec = _filters(+ [("JFK", "LAX", OUTBOUND_DATE), ("LAX", "JFK", RETURN_DATE)],+ trip_type=TripType.ROUND_TRIP,+ )+ spec.flight_segments[0].selected_flight = _flight()+ raw = _decode(build_tfs(spec))+ # Field 4, length-delimited: tag 0x22, then a body naming the flight.+ assert b"\x22" in raw+ assert b"AA" in raw and b"171" in raw+ index = raw.index(b"171")+ assert raw[index - 2] == 0x32, "flight number should sit in leg field 6"++ def test_passenger_mix_is_repeated_per_traveller(self):+ spec = _filters(+ [("JFK", "LAX", OUTBOUND_DATE)],+ passenger_info=PassengerInfo(adults=2, children=1),+ )+ raw = _decode(build_tfs(spec))+ assert raw.count(b"\x40\x01") == 2, "two adults means two field-8 entries"+ assert b"\x40\x02" in raw, "a child means a field-8 entry with code 2"++ def test_cabin_class_is_encoded(self):+ economy = build_tfs(_filters([("JFK", "LAX", OUTBOUND_DATE)]))+ business = build_tfs(_filters([("JFK", "LAX", OUTBOUND_DATE)], seat_type=SeatType.BUSINESS))+ assert economy != business++ def test_trip_type_field_19(self):+ """Field 19 must say one-way (2) or round trip (1), never anything else."""+ one_way = _decode(build_tfs(_filters([("JFK", "LAX", OUTBOUND_DATE)])))+ round_trip = _decode(+ build_tfs(+ _filters(+ [("JFK", "LAX", OUTBOUND_DATE), ("LAX", "JFK", RETURN_DATE)],+ trip_type=TripType.ROUND_TRIP,+ )+ )+ )+ assert one_way.endswith(b"\x98\x01\x02")+ assert round_trip.endswith(b"\x98\x01\x01")++ def test_multi_city_is_refused(self):+ """Encoding it as one-way would return the first leg's board as the trip."""+ spec = _filters(+ [+ ("MNL", "DXB", "2026-10-12"),+ ("DXB", "FCO", "2026-10-16"),+ ("FCO", "MNL", "2026-10-25"),+ ],+ trip_type=TripType.MULTI_CITY,+ )+ with pytest.raises(SearchUnsupportedError, match="Multi-city"):+ build_tfs(spec)+++class TestPassengerCodes:+ """Each ``PassengerInfo`` field must map to the wire code Google means.++ These codes are money: on an international route a lap infant prices at+ roughly 10% of the adult fare while an infant in its own seat prices like+ a child, at roughly 100%. Swapping the two codes produces a plausible,+ non-erroring search that quotes the wrong fare — verified live on a fixed+ BA178 JFK->LHR economy itinerary, where ``[1, 3]`` quoted $324 (+10%) and+ ``[1, 4]`` quoted $589 (+100%) against a $295 solo-adult baseline.++ The legacy RPC struct in ``fli.models.google_flights.flights`` orders the+ same four counts ``[adults, children, infants_on_lap, infants_in_seat]``,+ which is the ordering these codes follow.+ """++ @pytest.mark.parametrize(+ ("field", "code"),+ [+ ("adults", 1),+ ("children", 2),+ ("infants_on_lap", 3),+ ("infants_in_seat", 4),+ ],+ )+ def test_each_passenger_kind_has_its_wire_code(self, field: str, code: int) -> None:+ """One adult plus one traveller of the kind under test.++ Every mix here must satisfy ``PassengerInfo``'s own rules (1-9+ travellers, and a lap infant needs an adult to sit with), so the+ baseline adult is always present rather than zeroed out.+ """+ counts = {"adults": 1}+ counts[field] = counts.get(field, 0) + 1+ spec = _filters(+ [("JFK", "LAX", OUTBOUND_DATE)],+ passenger_info=PassengerInfo(**counts),+ )+ assert _passenger_codes(build_tfs(spec)) == [1, code]++ def test_lap_infant_is_three_not_four(self):+ """Pinned separately: this is the swap that quoted a lap infant a seat fare."""+ lap = _filters(+ [("JFK", "LAX", OUTBOUND_DATE)],+ passenger_info=PassengerInfo(adults=1, infants_on_lap=1),+ )+ seat = _filters(+ [("JFK", "LAX", OUTBOUND_DATE)],+ passenger_info=PassengerInfo(adults=1, infants_in_seat=1),+ )+ assert _passenger_codes(build_tfs(lap)) == [1, 3]+ assert _passenger_codes(build_tfs(seat)) == [1, 4]++ def test_family_mix_emits_one_entry_per_traveller(self):+ spec = _filters(+ [("JFK", "LAX", OUTBOUND_DATE)],+ passenger_info=PassengerInfo(adults=2, children=1, infants_in_seat=1, infants_on_lap=1),+ )+ assert _passenger_codes(build_tfs(spec)) == [1, 1, 2, 3, 4]++ def test_default_is_a_single_adult(self):+ spec = _filters([("JFK", "LAX", OUTBOUND_DATE)])+ assert _passenger_codes(build_tfs(spec)) == [1]++ def test_encodes_the_validator_boundary_mixes(self):+ """The largest and most lap-heavy mixes `PassengerInfo` permits.++ ``PassengerInfo`` caps a booking at nine travellers and requires one+ adult per lap infant, so these two are the edges the encoder has to+ keep handling — one entry per traveller, in field order.+ """+ full_house = _filters(+ [("JFK", "LAX", OUTBOUND_DATE)],+ passenger_info=PassengerInfo(adults=4, children=2, infants_in_seat=2, infants_on_lap=1),+ )+ assert _passenger_codes(build_tfs(full_house)) == [1, 1, 1, 1, 2, 2, 3, 4, 4]++ one_lap_each = _filters(+ [("JFK", "LAX", OUTBOUND_DATE)],+ passenger_info=PassengerInfo(adults=2, infants_on_lap=2),+ )+ assert _passenger_codes(build_tfs(one_lap_each)) == [1, 1, 3, 3]+++class TestPageUrl:+ def test_includes_locale_and_currency(self):+ url = page_url("TFS", currency="EUR", language="de", country="DE")+ assert "tfs=TFS" in url and "curr=EUR" in url and "hl=de" in url and "gl=DE" in url++ def test_defaults_when_locale_omitted(self):+ url = page_url("TFS")+ assert "hl=en" in url and "gl=US" in url and "curr=" not in url+++class TestExtractPayload:+ def test_reads_the_ds1_blob(self):+ html = (+ "<script>AF_initDataCallback({key: 'ds:0', hash: '1', "+ 'data:["other"], sideChannel: {}});</script>'+ "<script>AF_initDataCallback({key: 'ds:1', hash: '2', "+ 'data:[1,2,[["row"]]], sideChannel: {}});</script>'+ )+ assert extract_payload(html) == [1, 2, [["row"]]]++ def test_returns_none_without_ds1(self):+ html = (+ "<script>AF_initDataCallback({key: 'ds:4', hash: '2', "+ "data:[], sideChannel: {}});</script>"+ )+ assert extract_payload(html) is None++ def test_returns_none_on_unparseable_blob(self):+ html = (+ "<script>AF_initDataCallback({key: 'ds:1', hash: '2', "+ "data:[oops, sideChannel: {}});</script>"+ )+ assert extract_payload(html) is None+++class TestClientSideFilters:+ def test_airline_include_keeps_only_matching_carriers(self):+ flights = [_flight(Airline.AA), _flight(Airline.DL)]+ spec = _filters([("JFK", "LAX", OUTBOUND_DATE)], airlines=[Airline.AA])+ kept = apply_client_side_filters(flights, spec)+ assert [leg.airline for f in kept for leg in f.legs] == [Airline.AA]++ def test_airline_exclude_drops_matching_carriers(self):+ flights = [_flight(Airline.AA), _flight(Airline.DL)]+ spec = _filters([("JFK", "LAX", OUTBOUND_DATE)], airlines_exclude=[Airline.AA])+ kept = apply_client_side_filters(flights, spec)+ assert [leg.airline for f in kept for leg in f.legs] == [Airline.DL]++ def test_price_cap_drops_expensive_flights(self):+ flights = [_flight(price=100), _flight(price=900)]+ spec = _filters([("JFK", "LAX", OUTBOUND_DATE)], price_limit=PriceLimit(max_price=500))+ assert [f.price for f in apply_client_side_filters(flights, spec)] == [100]++ def test_max_duration_drops_long_flights(self):+ flights = [_flight(duration=120), _flight(duration=600)]+ spec = _filters([("JFK", "LAX", OUTBOUND_DATE)], max_duration=300)+ assert [f.duration for f in apply_client_side_filters(flights, spec)] == [120]++ def test_departure_window_drops_flights_outside_it(self):+ flights = [_flight(hour=6), _flight(hour=20)]+ spec = _filters(+ [("JFK", "LAX", OUTBOUND_DATE)],+ time_restrictions=TimeRestrictions(earliest_departure=8, latest_departure=22),+ )+ kept = apply_client_side_filters(flights, spec)+ assert [f.legs[0].departure_datetime.hour for f in kept] == [20]++ def test_window_follows_the_segment_being_chosen(self):+ """Return-leg candidates honour the return window, not the outbound one.++ During round-trip expansion the outbound is already pinned and the+ rows coming back are return options. Filtering them against segment+ zero's window drops valid returns and keeps invalid ones without ever+ raising.+ """+ spec = FlightSearchFilters(+ trip_type=TripType.ROUND_TRIP,+ passenger_info=PassengerInfo(adults=1),+ flight_segments=[+ FlightSegment(+ departure_airport=[[Airport.JFK, 0]],+ arrival_airport=[[Airport.LAX, 0]],+ travel_date=OUTBOUND_DATE,+ time_restrictions=TimeRestrictions(earliest_departure=5, latest_departure=9),+ selected_flight=_flight(hour=6),+ ),+ FlightSegment(+ departure_airport=[[Airport.LAX, 0]],+ arrival_airport=[[Airport.JFK, 0]],+ travel_date=RETURN_DATE,+ time_restrictions=TimeRestrictions(earliest_departure=18, latest_departure=23),+ ),+ ],+ stops=MaxStops.ANY,+ seat_type=SeatType.ECONOMY,+ )+ returns = [_flight(hour=6), _flight(hour=20)]+ kept = apply_client_side_filters(returns, spec)+ hours = [f.legs[0].departure_datetime.hour for f in kept]+ assert hours == [20], f"expected the 20:00 return to survive, got {hours}"++ def test_window_applies_to_outbound_before_anything_is_pinned(self):+ """With nothing selected yet, segment zero's window is the right one."""+ spec = FlightSearchFilters(+ trip_type=TripType.ROUND_TRIP,+ passenger_info=PassengerInfo(adults=1),+ flight_segments=[+ FlightSegment(+ departure_airport=[[Airport.JFK, 0]],+ arrival_airport=[[Airport.LAX, 0]],+ travel_date=OUTBOUND_DATE,+ time_restrictions=TimeRestrictions(earliest_departure=5, latest_departure=9),+ ),+ FlightSegment(+ departure_airport=[[Airport.LAX, 0]],+ arrival_airport=[[Airport.JFK, 0]],+ travel_date=RETURN_DATE,+ time_restrictions=TimeRestrictions(earliest_departure=18, latest_departure=23),+ ),+ ],+ stops=MaxStops.ANY,+ seat_type=SeatType.ECONOMY,+ )+ kept = apply_client_side_filters([_flight(hour=6), _flight(hour=20)], spec)+ assert [f.legs[0].departure_datetime.hour for f in kept] == [6]++ def test_no_filters_keeps_everything(self):+ flights = [_flight(Airline.AA), _flight(Airline.DL)]+ spec = _filters([("JFK", "LAX", OUTBOUND_DATE)])+ assert apply_client_side_filters(flights, spec) == flights+++class TestUnsupportedFilters:+ def test_reports_nothing_for_a_plain_search(self):+ assert unsupported_filters(_filters([("JFK", "LAX", OUTBOUND_DATE)])) == []++ def test_names_filters_the_page_cannot_honour(self):+ spec = _filters([("JFK", "LAX", OUTBOUND_DATE)])+ spec.exclude_basic_economy = True+ assert "exclude_basic_economy" in unsupported_filters(spec)+++class TestAllianceAndLayoverEncoding:+ """Alliances and layover bounds ride in the request, not a post-filter.++ Google reads both out of the segment, so a search that sets them comes+ back already filtered — and back-filled, which a client-side filter+ can't do.+ """++ def test_alliances_ride_in_the_carrier_include_list(self):+ spec = _filters([("JFK", "LAX", OUTBOUND_DATE)])+ spec.alliances = [Alliance.STAR_ALLIANCE]+ raw = _decode(build_tfs(spec))+ # Field 6, length-delimited: tag 0x32, length 13, then the name.+ assert b"\x32\x0dSTAR_ALLIANCE" in raw++ def test_alliances_exclude_uses_the_exclude_list(self):+ spec = _filters([("JFK", "LAX", OUTBOUND_DATE)])+ spec.alliances_exclude = [Alliance.ONEWORLD]+ raw = _decode(build_tfs(spec))+ # Field 7, length-delimited: tag 0x3a, length 8, then the name.+ assert b"\x3a\x08ONEWORLD" in raw++ def test_layover_restrictions_are_encoded(self):+ spec = _filters([("JFK", "LAX", OUTBOUND_DATE)])+ spec.layover_restrictions = LayoverRestrictions(+ airports=[Airport.ORD], min_duration=120, max_duration=300+ )+ raw = _decode(build_tfs(spec))+ assert b"\x7a\x03ORD" in raw, "layover airport should sit in field 15"+ assert b"\x88\x01\x78" in raw, "min layover should sit in field 17"+ assert b"\x90\x01\xac\x02" in raw, "max layover should sit in field 18"++ def test_unset_filters_leave_the_bytes_alone(self):+ """A plain search must still match the tfs Google issues for it."""+ assert build_tfs(_filters([("JFK", "LAX", OUTBOUND_DATE)])) == TFS_ONE_WAY++ def test_alliances_and_layovers_are_no_longer_unsupported(self):+ spec = _filters([("JFK", "LAX", OUTBOUND_DATE)])+ spec.alliances = [Alliance.SKYTEAM]+ spec.layover_restrictions = LayoverRestrictions(min_duration=90)+ assert unsupported_filters(spec) == []diff --git a/tests/search/test_wire.py b/tests/search/test_wire.pyindex 05fa22e..4e60f60 100644--- a/tests/search/test_wire.py+++ b/tests/search/test_wire.py@@ -2,7 +2,10 @@import json+import pytest+from fli.search._wire import iter_wrb_chunks, parse_first_wrb_payload+from fli.search.exceptions import SearchRejectedErrordef _single_chunk(payload):@@ -141,3 +144,42 @@ class TestParseFirstWrbPayloadEdgeCases:outer = [["wrb.fr", None, bad_inner], ["wrb.fr", None, good_inner]]body = ")]}'\n\n" + json.dumps(outer)assert parse_first_wrb_payload(body) == [42]+++class TestPayloadLessRowIsRejection:+ """Google's gated RPC answers HTTP 200 with a payload-less row + error 13.++ Yielding nothing there made a hard block indistinguishable from a route+ with no service, which is what left every search reporting "no flights".+ """++ @staticmethod+ def _rejection(code):+ outer = [["wrb.fr", None, None, None, None, [code, "generic::internal: ..."], "generic"]]+ return ")]}'\n\n" + json.dumps(outer)++ def test_error_13_raises_search_rejected(self):+ with pytest.raises(SearchRejectedError) as excinfo:+ list(iter_wrb_chunks(self._rejection(13)))+ assert excinfo.value.code == 13+ assert "error 13" in str(excinfo.value)++ def test_rejection_is_exported_from_fli_search(self):+ from fli.search import SearchRejectedError as exported++ assert exported is SearchRejectedError++ def test_parse_first_payload_also_raises(self):+ with pytest.raises(SearchRejectedError):+ parse_first_wrb_payload(self._rejection(13))++ def test_any_numeric_code_is_reported(self):+ with pytest.raises(SearchRejectedError) as excinfo:+ list(iter_wrb_chunks(self._rejection(7)))+ assert excinfo.value.code == 7++ def test_non_numeric_code_is_skipped_not_raised(self):+ """Without a numeric code there is nothing to report — stay silent."""+ outer = [["wrb.fr", None, None, None, None, ["not-a-code"]]]+ body = ")]}'\n\n" + json.dumps(outer)+ assert list(iter_wrb_chunks(body)) == []