Repository navigation
fix(cli): refuse to share an unresolved code, send a numeric city code as cityCode (PET-508) - #115
ahsan-amin-wego wants to merge 7 commits into
Conversation
|
I'll fix CI failures and address comments from users with write access. I'll skip comments containing "(aside)".
Original prompt from Ahsan.amin
|
|
Important Review skippedAuto incremental reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the
|
| Layer / File(s) | Summary |
|---|---|
Resolve codes before link creation src/commands.ts, src/index.ts |
Flight shares require exact, case-insensitive city or airport matches. Hotel shares require exact, case-insensitive city matches. Unresolved codes produce guidance and EXIT.PERMANENT. buildRealDeps supplies fetchPlaces to both commands. |
Resolve numeric hotel locations src/commands.ts, src/hotels.test.ts, integration/hotels.test.ts, contract/openapi.json |
Hotel search uses cityCode when Places returns a matching city for an all-digit location. Otherwise, it retains the hotelId. Tests cover matching and non-matching results. The OpenAPI contract documents numeric city codes and removes the three-uppercase-letter restriction from cityCode. |
Exercise share resolution integration/harness/fixtures.ts, integration/flights.test.ts, integration/hotels.test.ts |
The placesKnowing fixture returns configured Places results and an empty result for other queries. Integration tests cover accepted and unresolved codes, guidance, and cases where no link request occurs. |
API Contract Metadata
| Layer / File(s) | Summary |
|---|---|
Update API metadata contract/openapi.json |
The OpenAPI version changes to 0.19.5, the documentation URL changes to agents.wego.com, and the OAuth2 authorization and token URLs use auth.example.invalid. |
Estimated code review effort: 3 (Moderate) | ~25 minutes
Sequence Diagram(s)
sequenceDiagram
participant flightsShare
participant hotelsShare
participant fetchPlaces
participant SearchLink
participant HotelLink
flightsShare->>fetchPlaces: Resolve origin and destination
fetchPlaces-->>flightsShare: Return Places results
alt Both codes match allowed place types
flightsShare->>SearchLink: Request flight share link
else A code is unresolved
flightsShare-->>flightsShare: Report unresolved code and return EXIT.PERMANENT
end
hotelsShare->>fetchPlaces: Resolve city
fetchPlaces-->>hotelsShare: Return Places results
alt City code matches
hotelsShare->>HotelLink: Request hotel share link
else City code is unresolved
hotelsShare-->>hotelsShare: Report unresolved city and return EXIT.PERMANENT
end
Merge Risk: 
Low · previous review 05097
-
Share commands now refuse unresolved codes, and numeric hotel locations are checked against Places before being sent as cityCode. One minor edge case remains: a zero-prefixed numeric location such as 008283 can be matched as city code 8283. This is easy to fix and does not block merging.
Pre-merge checks: 
4
-
Full details: Title check
-
Explanation
The title follows Conventional Commits. Type fix and scope cli are valid. The subject is imperative and lowercase. It describes the main change: the share commands refuse unresolved codes, and hotel searches send numeric city codes as cityCode. The PET-508 key is extra context and does not conflict with the requirements. No breaking-change marker is needed, because the change adds refusal behavior and does not alter the wire contract shape or stdout format.
-
- Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
flights share and hotels share now resolve each code through GET /v1/places before building a durable link. A code with no exact match exits 6 with no link, instead of exit 0 and a dead URL. Co-Authored-By: ahsan.amin@wego.com <ahsan.amin@wego.com>
Co-Authored-By: ahsan.amin@wego.com <ahsan.amin@wego.com>
e430c37 to
a2344fd
Compare
Co-Authored-By: ahsan.amin@wego.com <ahsan.amin@wego.com>
…o a city Co-Authored-By: ahsan.amin@wego.com <ahsan.amin@wego.com>
GET /v1/places now also matches an all-digit query as a city code. Co-Authored-By: ahsan.amin@wego.com <ahsan.amin@wego.com>
When the top place Places returns for an all-digit location is the city with that exact code, hotels search sends it as cityCode. Makkah has no airport and is 8283. Any other number stays a hotelId. Co-Authored-By: ahsan.amin@wego.com <ahsan.amin@wego.com>
|
@coderabbitai review |
Action performed
|
008283 is no exact match for city code 8283, so it stays a hotelId. Co-Authored-By: ahsan.amin@wego.com <ahsan.amin@wego.com>
PET-508 · Share half of PET-508, and the CLI half of Makkah
8283. The search errors and the numeric Places lookup are in wego/wego-ai#2132.Summary
flights shareandhotels sharebuilt a durable link from the raw codes, so an unknown code such asZZZexited 0 with a dead URL. Each code is now looked up throughGET /v1/placesfirst. A code with no exact match exits 6 (EXIT.PERMANENT, the class ofvalidation_failed) and builds no link.Numeric hotel search.
hotels search 8283senthotelId: 8283. Makkah has no airport, so8283is its city code. An all-digit location is now looked up withgetPlaces(types=city). If the top place is the city with exactly that code, the CLI sendscityCode. Otherwise it sendshotelId. A failed lookup other than a 401 keeps the hotelId.A valid share makes one or two extra
getPlacesreads. The shape checks in the parsers (usage errors, exit 2) are unchanged.Verification
Local API (
apps/api,bun src/dev.ts, local JWKS) with the CLI pointed at it byWEGO_API_URL. main = CLImain(1.5.1) + APImain. PR = CLI05097ed8+ API wego/wego-ai#2132 at3e16e40b. Upstreams are production:SRV_WEGO_BASE_URL=https://srv.wego.com,HOTELS_METASEARCH_BASE_URL=https://www.wego.com/kong/v3/metasearch/hotels, flightshttps://api.wego.com.GENZO_API_URL,POSTHOG_API_KEYandPOSTHOG_KEYare unset, so no analytics left the machine. Dates are 2027-01-20/22.hotelId, 404Unknown hotel or city.cityCode: "8283",searchId884506f88954332d,settled: converged, 10 of 183 hotels, allcityName: "Makkah"hotels search 999999999 2027-01-20 2027-01-22(no city)Unknown hotel or city.hotelId, 404Unknown hotel.flights share ZZZ CAI 2027-01-20searchUrl …/zzz-cai-2027-01-20/…No link was built: the from code "ZZZ" resolves to no city or airport. Find one with \wego places ` and pass the code it reports.`hotels share ZZZ 2027-01-20 2027-01-22searchUrl …/hotels/searches/zzz/…No link was built: the city code "ZZZ" resolves to no city. …flights share ZZZ QQQ 2027-01-20hotels share LHR 2027-01-20 2027-01-22(airport)…/hotels/searches/lhr/…the city code "LHR" resolves to no cityflights share DXB CAI 2027-01-20searchUrl …/dxb-cai-2027-01-20/…hotels share DXB 2027-01-20 2027-01-22searchUrl …/hotels/searches/dxb/…flights search ZZZ CAI 2027-01-20bad_gatewayvalidation_failed(API PR)hotels search ZZZ 2027-01-20 2027-01-22Unknown hotel or city.validation_failed(API PR)info schedules ZZZ CAIvalidation_failedflights search ABCD CAI 2027-01-20from must be a 3-letter IATA codeflights search DXB CAI 2027-01-20searchIdsearchIdhotels search DXB 2027-01-20 2027-01-22Done when (PET-508)
validation_failed, code, recovery,trace_idfake.requests("getFlightSearchLink")/getHotelSearchLinkempty)8283gives no 502: it says what is wrong or succeedscityCode, MakkahsearchIdand results (first row). A number that is no city stays a hotelIdABCDshape error,DXB CAIsearchIdDXBstill exits 0 with the same URLQA plan
wego flights share ZZZ CAI 2026-12-20on the released CLINo link was built …, empty stdoutecho $?wego hotels share ZZZ 2026-12-20 2026-12-22wego hotels search 8283 2027-01-20 2027-01-22wego flights share DXB CAI 2026-12-20andwego hotels share DXB …searchUrlNotes for reviewers
https://api.wego.comas production serves it. Production still serves 0.19.3, so the non-blocking contract drift step warns until #2132 ships. Merge #2132 first: without its numeric lookup,8283stays a hotelId.validation_failed.Details for AI and humans who like to read everything
Files
src/commands.tsfetchPlacesinFlightsDepsandHotelsDeps.unresolvedShareCodes(a city row matches bycode ?? cityCode, as the API reads it),unresolvedShareMessage,SharePlan<T>.flightsShareandhotelsShareresolve inside the samewithAccessTokencall, so a 401 refresh covers the lookup too.src/commands.ts(hotels search)numericCityCodereads the top place;withNumericCityturns an all-digithotelIdintocityCodeinsidewithAccessTokensrc/hotels.test.tsnumericCityCode: exact city bycodeorcityCode, other code, a hotel, no resultscontract/openapi.jsonsrc/index.tsfetchPlacesinto the flights and hotels depsintegration/harness/fixtures.tsplacesKnowing({ CODE: type }):getPlacesroutes byquery, and a fallback with no resultsintegration/flights.test.ts,integration/hotels.test.tsZZZrefused (exit 6, no link request,types=cityfor hotels), both codes named, airport accepted for flights, airport refused for hotels, a city reported bycityCodealone accepted,--from-citywith an airport-only code refused;hotels search 8283with a Places city sendscityCode, a number with no city sendshotelIdEvidence:
bun run check1464 pass.bun run test:integration544 pass. All commits signed and Verified. Raw command outputs: one file per row, produced by a script that runs./.bin/wegowithXDG_CONFIG_HOMEpointing at locally minted credentials.🤖 Generated with Devin
Summary by CodeRabbit
🟢 Devin Review found nothing to fix · View findings · Follow Devin's work