Lovable Troubleshooting

Common issues when building the flight booking app in Lovable, and the exact instruction to paste back into Lovable's chat to fix each one.

Connection & Setup

ProblemTell Lovable
All flight searches fail or server calls return 500 / 401Verify Lovable Cloud secrets are set: VOLT_API_KEY, VOLT_USER_ID, VOLT_MERCHANT_ID, VOLT_AUTH_URL, VOLT_FLIGHTS_API_URL, and VOLT_SOURCE=website. Ensure volt.server.ts handles token generation and refreshes automatically on 401.
Search works in Sandbox but fails in ProductionSwitch all three production values together: set production VOLT_AUTH_URL, production VOLT_FLIGHTS_API_URL, and production API credentials. Never mix sandbox credentials with production URLs.
"My Bookings" page is empty even after booking attemptsEnsure the public.bookings Postgres table exists with appropriate RLS policies and grants. The booking server function must insert a record on every booking attempt (CONFIRMED, FAILED, or PENDING), never just for successful ones.
Database permission denied when saving bookingsCheck that GRANT SELECT, INSERT ON public.bookings TO anon, authenticated; was executed alongside RLS policies so public client sessions can read and record their bookings.

Flight Workflow & API Logic

ProblemTell Lovable
Search returns 422 or fails on datesOn one-way searches, omit preferredReturnDepartureTimeentirely (do not pass null). On round-trip searches, ensure the return date is at least 2 calendar days after departure per sandbox rules.
Search session expired after selecting a flighUpstream search sessions have short TTLs. When upstream returns errorCode: 6, show: "This search session has expired. Search again to see live fares." and direct the user to search again instead of showing a generic crash.
International return flights missing or crash selectionInternational round-trips use nested arrays (outboundFlights[].inboundFlights[]), while domestic uses parallel outboundFlights and inboundFlights. Use flightKeys.ts helpers to resolve both shapes seamlessly.
Search or fare rules trigger duplicate API requestsEnsure React 18 StrictMode double-invocations are guarded using inflight request refs and lastQueryKey deduplication in searchStore so requests are only dispatched once per user action.
Passenger form rejects submit or asks for unneeded fieldsMandatory passenger fields must be derived strictly from the itinerary's paxRules (isVisible and isMandatoryIfVisible). Do not hardcode passport numbers or GST details as globally mandatory.
Reprice or Save Passenger halts on duplicate booking warningWhen the passenger endpoint returns duplicatesFound: true, treat it as an advisory notice rather than an error: display the warning banner and still allow the user to advance to reprice and booking.
Booking API fails with validation errorThe upstream booking endpoint requires only {traceId} in its request body. Strip all UI metadata, passenger objects, and fare fields before sending the payload upstream.

Edge Functions & Errors

ProblemTell Lovable
CORS errors in browser console when calling Edge FunctionsAll Edge Functions must set CORS headers for the Lovable frontend origin on every response, including errors.

Quick Mega-Fix

If the build has drifted off-spec in several places at once, paste this single message into Lovable instead of fixing things one at a time:

Re-align with the full flight engine specification:
1. Server Proxy: All VOLT API requests (search, fare rules, create/get itinerary, passengers, reprice, book, booking details) must be securely proxied server-side with token caching and 401 refresh. No VOLT credentials or tokens in the client.

2. Persistence: Ensure public.bookings table has RLS policies and grants. Save every booking attempt with status CONFIRMED, FAILED, or PENDING.

3. Flow & Keys: Search → Fare Rules → Create Itinerary → Get Itinerary (paxRules) → Passengers (advisory duplicates pass-through) → Reprice (/fare-quote) → Book (only { traceId } in body) → Confirmation (route from itemFlight).

4. Error Rules: UI must never display "VOLT", "Travclan", or status codes; route all errors through friendlyApiMessage.

5. Paper UI: Clean white background, hairline borders (#e5e7eb), static airport picker, no chips/gradients, and brand theme flowing solely from src/config/brand.ts.

Did this page help you?