Skip to content

fix(duffel): target Duffel API v2 /air endpoints - #17

Merged
manish-wekan merged 1 commit into
nitrocloudofficial:developfrom
aviabhijit55-ship-it:fix/duffel-v2-air-endpoints
Sep 8, 2026
Merged

fix(duffel): target Duffel API v2 /air endpoints#17
manish-wekan merged 1 commit into
nitrocloudofficial:developfrom
aviabhijit55-ship-it:fix/duffel-v2-air-endpoints

Conversation

@aviabhijit55-ship-it

@aviabhijit55-ship-it aviabhijit55-ship-it commented Sep 8, 2026

Copy link
Copy Markdown
Contributor

Problem

Every DuffelService request returns HTTP Error 404: Not Found as soon as a real DUFFEL_API_KEY is configured. The client sends Duffel-Version: v1 and omits the /air namespace that Duffel API v2 requires.

This was invisible until now because _is_mock_key() routes the shipped placeholder key (your-duffel-api-key) into mock mode, which never calls _request. The defect only surfaces the first time the python-oauth template is used with a genuine key.

Evidence

Version header Path Status
v1 /airlines 404
v2 /airlines 404
v2 /air/airlines 200
v2 /places/suggestions?query=London 200

Changes

  • Duffel-Version: v1 -> v2
  • /air prefix on offer_requests, offers/{id}, seat_maps, orders (POST and GET), order_cancellations, airlines
  • search_airports now calls /places/suggestions. The old /air/suggestions call and its /places?type=airport fallback are both non-existent endpoints, so the try/except only ever traded one 404 for another.
  • Same fix applied to the duplicate service inlined in nitrostack/cli/main.py

Verification

Ran the patched service against the live Duffel API with a test key: get_airlines returned 50 airlines, search_airports("London") returned 14 hits led by LON, and search_flights(JFK->LAX) returned 73 real offers.

New regression test pins the method, URL, and version header for all eight calls against a stubbed urlopen. Full suite green.

Not included

Two things are deliberately out of scope, each worth its own PR:

  • A third copy of this service lives in examples/flight_booking_server.py (lines 108-340) with the same defect.
  • 23 stale .pyc files are tracked in git despite the __pycache__/ ignore rule, which only applies to untracked paths.

Every DuffelService request 404'd as soon as a real DUFFEL_API_KEY was
configured. Two causes: the client sent `Duffel-Version: v1`, and the
flight endpoints omitted the `/air` namespace that v2 requires.

Verified against the live API with a test key: `v2 + /air/airlines` and
`v2 + /places/suggestions` return 200, while `v1 + /airlines` and
`v2 + /airlines` both 404.

- Duffel-Version: v1 -> v2
- /air prefix on offer_requests, offers, seat_maps, orders (POST + GET),
  order_cancellations and airlines
- search_airports now calls /places/suggestions; the previous
  /air/suggestions call and its /places?type=airport fallback were both
  non-existent endpoints, so the try/except only ever traded one 404 for
  another
- same fix applied to the copy inlined in the CLI scaffolder

The defect was invisible until now because _is_mock_key() routes the
shipped placeholder key into mock mode, which never calls _request, so
it only surfaced the first time the template was used for real.

Adds a regression test that pins the method, URL and version header for
all eight calls against a stubbed urlopen.

Co-authored-by: Cursor <[email protected]>
@aviabhijit55-ship-it
aviabhijit55-ship-it force-pushed the fix/duffel-v2-air-endpoints branch from cce9b9f to e57091a Compare September 8, 2026 06:46
@aviabhijit55-ship-it aviabhijit55-ship-it changed the title Fix/duffel v2 air endpoints fix(duffel): target Duffel API v2 /air endpoints Sep 8, 2026
@manish-wekan
manish-wekan merged commit 3390fc5 into nitrocloudofficial:develop Sep 8, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants