You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
POST /Booking returns 500 Internal Server Error instead of helpful 400 respons #1547
When API clients attempt to create Booking or BookingSupplement entities directly via POST /processor/Booking, they receive a 500 Internal Server Error that doesn't explain what went wrong or how to fix it.
A 400 Bad Request with a helpful message explaining that Booking entities must be created via their parent Travel entity:
{
"code": "400",
"message": "Bookings must be created in the context of a Travel draft. Use POST /processor/Travel(TravelUUID=<uuid>,IsActiveEntity=false)/to_Booking instead."
}
Booking and BookingSupplement are composition entities that can only be created via their parent (Travel → Booking → BookingSupplement).
The error occurs at the database layer and bubbles up as a generic 500 Internal Server Error.
No validation exists to catch this earlier and provide a helpful, actionable error message.
Proposed Solution
Add request validation handlers in srv/travel-service.ts:
A before handler to reject direct POST /Booking requests before they reach the database.
An on('error') handler as a fallback to catch any remaining database-level errors and convert them from 500 Internal Server Error to 400 Bad Request with actionable guidance.
Additional Issues Found
Potential null pointer crashes in existing handlers in srv/travel-service.ts:
update_totalsGreen() crashes when the Travel draft cannot be found.
deductDiscount() accesses travel.ID when travel is null.
Date validation is missing null checks before comparing dates.
Activity