Skip to content

fix: prevent 500 error when deleting calendar events with empty uid#27500

Merged
hbjORbj merged 28 commits intomainfrom
devin/1770026222-fix-empty-uid-delete-event
Feb 9, 2026
Merged

fix: prevent 500 error when deleting calendar events with empty uid#27500
hbjORbj merged 28 commits intomainfrom
devin/1770026222-fix-empty-uid-delete-event

Conversation

@hbjORbj
Copy link
Copy Markdown
Contributor

@hbjORbj hbjORbj commented Feb 2, 2026

What does this PR do?

Fixes a 500 error on /api/book/event that 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):

  • Logs an error and returns early if bookingRefUid is empty (before getCalendar call)
  • Provides visibility into when this edge case occurs

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)

  • I have self-reviewed the code (A decent size PR without self-review might be rejected).
  • I have updated the developer docs in /docs if this PR makes changes that would require a documentation change. N/A - no documentation changes needed.
  • I confirm automated tests are in place that prove my fix is effective or that my feature works.

@devin-ai-integration
Copy link
Copy Markdown
Contributor

🤖 Devin AI Engineer

I'll be helping with this pull request! Here's what you should know:

✅ I will automatically:

  • Address comments on this PR that start with 'DevinAI' or '@devin'.
  • Look at CI failures and help fix them

Note: I can only respond to comments from users who have write access to this repository.

⚙️ Control Options:

  • Disable automatic comment and CI monitoring

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Feb 2, 2026

E2E results are ready!

@devin-ai-integration devin-ai-integration bot force-pushed the devin/1770026222-fix-empty-uid-delete-event branch from 868cff6 to 4cabbae Compare February 2, 2026 12:38
@hbjORbj hbjORbj marked this pull request as ready for review February 3, 2026 10:23
@hbjORbj hbjORbj requested a review from a team as a code owner February 3, 2026 10:23
@graphite-app graphite-app bot added foundation core area: core, team members only labels Feb 3, 2026
@hbjORbj hbjORbj enabled auto-merge (squash) February 3, 2026 10:24
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 3 files

devin-ai-integration bot and others added 9 commits February 3, 2026 12:09
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>
@devin-ai-integration devin-ai-integration bot force-pushed the devin/1770026222-fix-empty-uid-delete-event branch from 0d9ba76 to 866bae9 Compare February 3, 2026 12:09
@keithwillcode
Copy link
Copy Markdown
Contributor

@paragon-evolve

@paragon-review
Copy link
Copy Markdown

paragon-review bot commented Feb 5, 2026

Paragon: tests updated

1 updated test generated for this PR.

Updated Tests

  • deleteEvent - should return early when bookingRefUid is empty — Adding new test to existing file

Accept Changes Open in Paragon

Details

Updated Tests

  • deleteEvent - should return early when bookingRefUid is empty (unit)

Copy link
Copy Markdown
Contributor Author

hbjORbj commented Feb 5, 2026

🧪 Tests Added by Paragon

The following test files have been added to this PR:

  • packages/features/calendars/lib/CalendarManager.test.ts

These tests were generated from an approved test proposal.


Generated with Paragon

@pull-request-size pull-request-size bot added size/L and removed size/S labels Feb 5, 2026
@paragon-review
Copy link
Copy Markdown

paragon-review bot commented Feb 5, 2026

Paragon: tests updated

1 updated test generated for this PR.

Updated Tests

  • CalendarManager.test.ts - deleteEvent tests — Adding new test to existing file

Accept Changes Open in Paragon

Details

Updated Tests

  • CalendarManager.test.ts - deleteEvent tests (unit)

@pull-request-size pull-request-size bot added size/M and removed size/L labels Feb 6, 2026
@hbjORbj hbjORbj requested a review from keithwillcode February 6, 2026 06:52
@hbjORbj
Copy link
Copy Markdown
Contributor Author

hbjORbj commented Feb 6, 2026

@keithwillcode I simplified the PR to be extra safe, lmk if you have any feedback !

@hbjORbj hbjORbj merged commit 6287026 into main Feb 9, 2026
52 of 53 checks passed
@hbjORbj hbjORbj deleted the devin/1770026222-fix-empty-uid-delete-event branch February 9, 2026 11:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants