[BUG] AI booking import fails silently when provider returns non-strict JSON via OpenAI-compatible endpoint
Pre-flight checklist
- I have searched existing issues and this bug has not been reported yet
- I am running the latest available version of TREK
- I have read the Troubleshooting guide and my issue is not covered there
TREK version
4.2.1
Describe the bug
AI booking import reports:
No reservations could be extracted from the uploaded files.
However, the configured LLM successfully recognizes the uploaded Airbnb booking PDF and extracts reservation data. TREK appears to discard the result because the returned payload is not strict JSON.
This makes the failure look like a document/extraction failure in the UI, although the model did identify the reservation.
Setup
- TREK: 4.2.1
- Deployment: Docker, self-hosted
- AI provider configuration: OpenAI-compatible endpoint through LiteLLM
- Upstream model/provider: Perplexity
- Import source: German Airbnb booking-confirmation PDF
- Mode: AI booking import / force AI parsing
Expected behavior
TREK should either:
- Import the recognized reservation successfully, or
- Show a useful error such as “LLM response was not valid JSON,” including a safe diagnostic message.
Ideally, structured extraction should use JSON Schema / provider-compatible structured output rather than relying only on json_object, or should include a robust JSON validation/repair fallback.
Actual behavior
The UI only shows:
No reservations could be extracted from the uploaded files.
TREK logs show that the PDF text is extracted successfully and that the model recognizes a lodging reservation and extracts the confirmation number. The model response is then not valid JSON, so no reservation is created.
Relevant redacted log excerpt:
[DEBUG] Extracted text from [redacted Airbnb PDF] (2864 chars):
Deine Reiseübersicht – Airbnb ...
[...]
[DEBUG] Raw LLM Response: [
'@type': 'LodgingReservation',
reservationFor: {},
reservationNumber: '[redacted]',The response is JavaScript-like rather than valid JSON:
- It begins with
[instead of{. - It uses single quotes.
- It contains unquoted object keys.
As a result, TREK appears unable to deserialize it and returns the generic “No reservations could be extracted” message.
Additional context
Before enabling LiteLLM's drop_params, LiteLLM returned:
UnsupportedParamsError: PERPLEXITY does not support parameters:
{'text': {'format': {'type': 'json_object'}}}Enabling drop_params allows the request to complete with HTTP 200, but removes the forced-JSON constraint. The model then returns useful reservation data in non-strict JSON-like syntax, which TREK rejects.
The PDF language does not appear to be the cause: German text is extracted correctly and the reservation is recognized.
There is also a locale warning:
Detected locale "C" with character encoding "ANSI_X3.4-1968", which is not UTF-8.The filename is garbled, but the extracted German document text itself is readable. This seems secondary to the JSON parsing failure.
Suggested improvement
- Support a configurable structured-output strategy for OpenAI-compatible providers.
- Prefer JSON Schema structured output where supported.
- Validate the response before silently treating it as “no reservation.”
- Return a clear user-facing message when the AI response cannot be parsed.
- Optionally add a guarded JSON repair step for common LLM output variations.
Saw similiar case with Antrophic with was fixed in 4.0.0 https://github.com/liketrek/TREK/issues/1968
Steps to reproduce
I can provide the Airbnb PDF if needed.
Expected behavior
Successfull Import of PDF JSON format issues fixed
Deployment method
Docker Compose
Host OS
No response
Accessing TREK from
Desktop browser
Browser (if applicable)
No response
Relevant logs or error output
Screenshots
No response
Additional context
No response
Source: liketrek/TREK