fix: prevent 500 error when deleting calendar events with empty uid#27500
Merged
fix: prevent 500 error when deleting calendar events with empty uid#27500
Conversation
Contributor
🤖 Devin AI EngineerI'll be helping with this pull request! Here's what you should know: ✅ I will automatically:
Note: I can only respond to comments from users who have write access to this repository. ⚙️ Control Options:
|
Contributor
E2E results are ready! |
868cff6 to
4cabbae
Compare
This fix addresses a 500 error that occurs when trying to delete a Google Calendar event with an empty event ID, which results in a malformed API URL. Root cause: When calendar event creation fails or returns without an ID, booking references were being created with empty uids. Later, when trying to delete these events (e.g., during reschedule), the empty uid caused a 404 from Google Calendar API which was then thrown as a 500 error. Changes: 1. CalendarManager.deleteEvent: Added validation to skip deletion if bookingRefUid is empty, with appropriate error logging. This is a safety net for existing bad data in the database. 2. EventManager.create: Added filtering to exclude booking references with empty uids from being stored, with error logging to help diagnose the root cause of missing event IDs. 3. EventManager.updateLocation: Same filtering applied for consistency. Co-Authored-By: benny@cal.com <sldisek783@gmail.com>
The test expects that booking references with empty uids are still created when calendar event creation fails. This is intentional behavior to track failed calendar syncs. The CalendarManager.deleteEvent fix handles the deletion case gracefully by skipping the API call when uid is empty. Co-Authored-By: benny@cal.com <sldisek783@gmail.com>
…fUid is empty Co-Authored-By: benny@cal.com <sldisek783@gmail.com>
…error - Add uid check in lastAttendeeDeleteBooking.ts before calling calendar.deleteEvent - Add uid check in EventManager.updateAllCalendarEvents before calling calendar.deleteEvent - Revert CalendarManager.deleteEvent changes (validation at call sites is the proper fix) Co-Authored-By: benny@cal.com <sldisek783@gmail.com>
…mpty bookingRefUid Co-Authored-By: benny@cal.com <sldisek783@gmail.com>
Co-Authored-By: benny@cal.com <sldisek783@gmail.com>
…event creation fails Root cause fix: Change the check from 'if (createdEvent)' to 'if (createdEvent.createdEvent)' in createAllCalendarEvents to prevent failed calendar events from being added to results. This prevents empty uids from being stored in the database in the first place, which was causing 500 errors when trying to delete non-existent calendar events later. Co-Authored-By: benny@cal.com <sldisek783@gmail.com>
… creation fails The root cause fix changes behavior so that failed calendar events no longer create booking references with empty uids. This test now expects an empty references array when calendar event creation fails, which is the correct behavior that prevents 500 errors later when trying to delete non-existent calendar events. Co-Authored-By: benny@cal.com <sldisek783@gmail.com>
Using success is more semantically clear since it explicitly checks the success status rather than checking if the nested object exists. Co-Authored-By: benny@cal.com <sldisek783@gmail.com>
0d9ba76 to
866bae9
Compare
Contributor
|
@paragon-evolve |
Generated by Paragon from proposal for PR #27500
Contributor
Author
🧪 Tests Added by ParagonThe following test files have been added to this PR:
These tests were generated from an approved test proposal. Generated with Paragon |
…elete-event' into devin/1770026222-fix-empty-uid-delete-event
Contributor
Author
|
@keithwillcode I simplified the PR to be extra safe, lmk if you have any feedback ! |
…empty-uid-delete-event
keithwillcode
approved these changes
Feb 9, 2026
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 do?
Fixes a 500 error on
/api/book/eventthat occurs when trying to delete a Google Calendar event with an empty event ID, resulting in a malformed API URL like/calendar/v3/calendars/primary/events/?sendNotifications=false&sendUpdates=none(missing event ID).Background
When calendar event creation fails during booking, a booking reference with
uid: ""is stored in the database. This is intentional behavior used by backfilling scripts to identify which bookings need calendar event backfilling. However, when the booking is later cancelled/rescheduled, the code attempts to delete this non-existent calendar event, causing a 500 error.Fix (defensive checks approach)
1.
CalendarManager.deleteEvent(safeguard):bookingRefUidis empty (beforegetCalendarcall)Why not fix the root cause?
The root cause (storing booking references with empty uids when calendar creation fails) is intentional - it's used by backfilling scripts to identify which bookings need calendar event backfilling. Changing this behavior would break existing workflows.
Mandatory Tasks (DO NOT REMOVE)