Skip to content

fix: rollback booking status to CANCELLED on calendar sync failure#28484

Open
sdip0971 wants to merge 1 commit intocalcom:mainfrom
sdip0971:fix/calendar-sync-rollback
Open

fix: rollback booking status to CANCELLED on calendar sync failure#28484
sdip0971 wants to merge 1 commit intocalcom:mainfrom
sdip0971:fix/calendar-sync-rollback

Conversation

@sdip0971
Copy link

@sdip0971 sdip0971 commented Mar 18, 2026

What this PR does
Fixes #28397
Fixes a state leak issue where a booking is permanently saved as ACCEPTED in the database even if EventManager.create fails to sync the event to the external calendar.

Previously, the backend would log the BookingCreatingMeetingFailed error but continue execution, returning a 200 OK to the frontend and resulting in a false "Success" UI state for the user.

How it works
This PR adds a synchronous compensation transaction inside RegularBookingService.ts. If the calendar integration fails:

It immediately executes a Prisma update to change the booking status to CANCELLED.

It sets a cancellationReason explicitly documenting the calendar integration failure.

It throws an HttpError(500) to halt backend execution. This forces the frontend's useMutation hook into its onError state, preventing the success redirect and ensuring the UI correctly displays the error toast.

Testing conditions (like isDryRun) are respected to ensure this doesn't break existing test suites.

@sdip0971 sdip0971 requested a review from a team as a code owner March 18, 2026 10:03
@graphite-app graphite-app bot added the community Created by Linear-GitHub Sync label Mar 18, 2026
@CLAassistant
Copy link

CLAassistant commented Mar 18, 2026

CLA assistant check
All committers have signed the CLA.

Copy link
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.

1 issue found across 1 file

Prompt for AI agents (unresolved issues)

Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.


<file name="packages/features/bookings/lib/service/RegularBookingService.ts">

<violation number="1" location="packages/features/bookings/lib/service/RegularBookingService.ts:2353">
P1: Booking cancellation is keyed to "all integrations failed" instead of calendar-sync failure, causing false cancellations and missed calendar-failure rollbacks.</violation>
</file>

Since this is your first cubic review, here's how it works:

  • cubic automatically reviews your code and comments on bugs and improvements
  • Teach cubic by replying to its comments. cubic learns from your replies and gets better over time
  • Add one-off context when rerunning by tagging @cubic-dev-ai with guidance or docs links (including llms.txt)
  • Ask questions if you need clarification on any suggestion

Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.

Copy link
Member

@sahitya-chandra sahitya-chandra left a comment

Choose a reason for hiding this comment

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

Can you add the steps for how to reproduce this issue?

and video evidence of the issue

@sdip0971 sdip0971 force-pushed the fix/calendar-sync-rollback branch from 18648c3 to 6755e91 Compare March 18, 2026 15:27
@github-actions github-actions bot added the 🐛 bug Something isn't working label Mar 18, 2026
@sdip0971
Copy link
Author

@sahitya-chandra Thanks for the review!

Steps to Reproduce:

  1. Connect a Google Calendar to a user profile.
  2. Force a calendar sync failure (e.g., manually corrupt the access token in the Credential table).
  3. Attempt to book a meeting on the frontend.
  4. Without this PR: The frontend incorrectly redirects to the green "Booking Confirmed" success page, even though the calendar API failed.
  5. With this PR: The backend catches the specific calendar integration failure, rolls the DB status back to CANCELLED, and throws a 500 error to ensure the frontend displays the correct failure toast.

Here is the video evidence of the fix successfully catching the failure and updating the UI:

Screen.Recording.2026-03-18.at.8.54.16.PM.mov

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

Labels

🐛 bug Something isn't working community Created by Linear-GitHub Sync size/S

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Booking Saved Without Calendar Event on External Sync Failure – Missing Atomicity / Rollback

3 participants