fix: set requestReschedule=true in BOOKING_CANCELLED webhook when booking has rescheduled=true#28665
Open
claygeo wants to merge 2 commits intocalcom:mainfrom
Open
Conversation
…king is rescheduled handleCancelBooking.ts hardcoded requestReschedule: false in the webhook payload, so callers via /api/cancel, CalendarSyncService, and platform libraries would always signal a permanent cancellation even when the booking was already marked rescheduled: true by requestReschedule.handler.ts. Fix: - Add rescheduled: true to the Prisma select in getBookingToDelete.ts so the field is available to handleCancelBooking.ts - Read bookingToDelete.rescheduled instead of hardcoding false The tRPC requestReschedule.handler.ts path already sends requestReschedule: true correctly. This fix closes the gap for all secondary cancellation paths. Adds a regression test covering the booking.rescheduled=true case. Fixes calcom#28543
The regression test used status=CANCELLED which causes handleCancelBooking to throw at line 201 before the webhook fires, making the test dead. Fixed by using status=ACCEPTED with rescheduled=true to simulate the narrow race window where rescheduled is set before status is updated. Also extends the same requestReschedule fix to cancelAttendeeSeat.ts line 169, which had the same hardcoded false for seated event attendee cancellations.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What does this PR fix?
Fixes #28543
handleCancelBooking.tshardcodedrequestReschedule: falseon line 458, meaning theBOOKING_CANCELLEDwebhook payload from that code path could never signal a reschedule-triggered cancellation — even if the booking was already markedrescheduled: truein the database.The tRPC
requestReschedule.handler.tspath (host clicks "Request Reschedule" in the UI) already correctly sendsrequestReschedule: trueviaBookingWebhookFactory. This fix closes the same gap for secondary cancellation paths that go throughhandleCancelBooking.ts:/api/cancelrouteCalendarSyncService(external calendar event deletion)Root cause
rescheduled(the DB field) was also not fetched ingetBookingToDelete.ts, so the fix required adding it to the Prisma select.Changes
packages/features/bookings/lib/getBookingToDelete.ts— addrescheduled: trueto the Prisma selectpackages/features/bookings/lib/handleCancelBooking.ts— readbookingToDelete.rescheduledinstead of hardcodingfalsepackages/features/bookings/lib/handleSeats/cancel/cancelAttendeeSeat.ts— same fix for the seated-event attendee cancellation path (line 169 also hardcodedfalse)packages/features/bookings/lib/handleCancelBooking/test/handleCancelBooking.test.ts— regression test covering therescheduled=truepathTest plan
cd packages/features/bookings && yarn test handleCancelBooking.test.tsBOOKING_CANCELLEDwebhook payload includesrequestReschedule: truerequestReschedule: false🤖 Generated with Claude Code