Skip to content

fix: set requestReschedule=true in BOOKING_CANCELLED webhook when booking has rescheduled=true#28665

Open
claygeo wants to merge 2 commits intocalcom:mainfrom
claygeo:fix/requestReschedule-webhook-flag-in-cancel-handler
Open

fix: set requestReschedule=true in BOOKING_CANCELLED webhook when booking has rescheduled=true#28665
claygeo wants to merge 2 commits intocalcom:mainfrom
claygeo:fix/requestReschedule-webhook-flag-in-cancel-handler

Conversation

@claygeo
Copy link
Copy Markdown

@claygeo claygeo commented Mar 29, 2026

What does this PR fix?

Fixes #28543

handleCancelBooking.ts hardcoded requestReschedule: false on line 458, meaning the BOOKING_CANCELLED webhook payload from that code path could never signal a reschedule-triggered cancellation — even if the booking was already marked rescheduled: true in the database.

The tRPC requestReschedule.handler.ts path (host clicks "Request Reschedule" in the UI) already correctly sends requestReschedule: true via BookingWebhookFactory. This fix closes the same gap for secondary cancellation paths that go through handleCancelBooking.ts:

  • /api/cancel route
  • CalendarSyncService (external calendar event deletion)
  • Platform libraries

Root cause

// handleCancelBooking.ts:458 — BEFORE
requestReschedule: false,  // always false, even if booking.rescheduled = true

// AFTER
requestReschedule: bookingToDelete.rescheduled ?? false,

rescheduled (the DB field) was also not fetched in getBookingToDelete.ts, so the fix required adding it to the Prisma select.

Changes

  • packages/features/bookings/lib/getBookingToDelete.ts — add rescheduled: true to the Prisma select
  • packages/features/bookings/lib/handleCancelBooking.ts — read bookingToDelete.rescheduled instead of hardcoding false
  • packages/features/bookings/lib/handleSeats/cancel/cancelAttendeeSeat.ts — same fix for the seated-event attendee cancellation path (line 169 also hardcoded false)
  • packages/features/bookings/lib/handleCancelBooking/test/handleCancelBooking.test.ts — regression test covering the rescheduled=true path

Test plan

  • Verify the new test passes: cd packages/features/bookings && yarn test handleCancelBooking.test.ts
  • Create a confirmed booking, request a reschedule as host, check that the BOOKING_CANCELLED webhook payload includes requestReschedule: true
  • Confirm normal cancellations still emit requestReschedule: false

🤖 Generated with Claude Code

claygeo added 2 commits March 29, 2026 19:24
…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.
@claygeo claygeo requested a review from a team as a code owner March 29, 2026 23:31
@github-actions github-actions bot added the 🐛 bug Something isn't working label Mar 29, 2026
Copy link
Copy Markdown
Contributor

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No issues found across 4 files

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

🐛 bug Something isn't working size/L

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Bug: rescheduledToUid Is null in BOOKING_CANCELLED Webhook When Triggered via "Request Reschedule"

1 participant