Merged
Conversation
…cal.com into feat/calendar_sync_cache
- Add tests for /api/cron/calendar-subscriptions-cleanup route (9 tests) - Add tests for /api/cron/calendar-subscriptions route (10 tests) - Add tests for /api/webhooks/calendar-subscription/[provider] route (11 tests) - Add missing feature flags for calendar-subscription-cache and calendar-subscription-sync - All 30 tests pass with comprehensive coverage of authentication, feature flags, error handling, and service instantiation Tests cover: - Authentication scenarios (API key validation, Bearer tokens, query parameters) - Feature flag combinations (cache/sync enabled/disabled states) - Success and error handling (including non-Error exceptions) - Service instantiation with proper dependency injection - Provider validation for webhook endpoints Co-Authored-By: Volnei Munhoz <volnei.munhoz@gmail.com>
…ositories, and adapters - Add unit tests for CalendarSubscriptionService with subscription, webhook, and event processing - Add unit tests for CalendarCacheEventService with cache operations and cleanup - Add unit tests for CalendarSyncService with Cal.com event filtering and booking operations - Add unit tests for CalendarCacheEventRepository with CRUD operations - Add unit tests for SelectedCalendarRepository with calendar selection management - Add unit tests for GoogleCalendarSubscriptionAdapter with subscription and event fetching - Add unit tests for Office365CalendarSubscriptionAdapter with placeholder implementation - Add unit tests for AdaptersFactory with provider management and adapter creation - Fix lint issues by removing explicit 'any' type casting and unused variables - All tests follow Cal.com conventions using Vitest framework with proper mocking Co-Authored-By: Volnei Munhoz <volnei.munhoz@gmail.com>
…g missing mocks - Add comprehensive mocks for defaultResponderForAppDir, logger, performance monitoring, and Sentry - Fix slow test execution (933ms -> <100ms) caused by missing dependency mocks - Ensure consistent test performance across different environments Co-Authored-By: Volnei Munhoz <volnei.munhoz@gmail.com>
Co-authored-by: Alex van Andel <me@alexvanandel.com>
This was referenced Dec 30, 2025
Co-Authored-By: Volnei Munhoz <volnei.munhoz@gmail.com>
…rSyncService Co-Authored-By: Volnei Munhoz <volnei.munhoz@gmail.com>
…port in server context Co-Authored-By: Volnei Munhoz <volnei.munhoz@gmail.com>
Contributor
E2E results are ready! |
…avoid RAQB import in server context Co-Authored-By: Volnei Munhoz <volnei.munhoz@gmail.com>
packages/features/calendar-subscription/lib/sync/CalendarSyncService.ts
Outdated
Show resolved
Hide resolved
Contributor
There was a problem hiding this comment.
1 issue found across 5 files
Prompt for AI agents (all issues)
Check if these issues are valid — if so, understand the root cause of each and fix them.
<file name="packages/features/bookings/lib/handleCancelBooking.ts">
<violation number="1" location="packages/features/bookings/lib/handleCancelBooking.ts:623">
P2: Avoid logging raw ZodError objects; log only sanitized fields (message/name) to prevent leaking sensitive data.
(Based on your team's feedback about not logging raw ZodError objects.) [FEEDBACK_USED]</violation>
</file>
Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.
Contributor
Devin AI is addressing Cubic AI's review feedbackA Devin session has been created to address the issues identified by Cubic AI. |
Add actionSource: "SYSTEM" to handleCancelBooking call after it became required, and mock @sentry/nextjs in test files.
keithwillcode
approved these changes
Feb 26, 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?
Implements calendar sync functionality that allows Cal.com to sync booking changes from external calendars (Google Calendar, Office365) back to Cal.com. When a user cancels or reschedules a Cal.com booking directly in their external calendar, the change is synced back to Cal.com.
Key Changes
Infinite Loop Prevention: Added flags to prevent infinite loops when calendar events are cancelled/rescheduled from external calendars:
skipCalendarSyncTaskCancellationflag inhandleCancelBooking- skips calendar event deletionskipCalendarSyncTaskCreationflag inhandleNewBooking- skips calendar event creation (existing)The flow is:
trueCalendarSyncService Implementation:
cancelBooking(): Cancels a booking when the corresponding calendar event is deleted (useshandleCancelBooking)rescheduleBooking(): Updates booking times when the calendar event is rescheduled (usesRegularBookingService.createBooking()directly withrescheduleUid)safeStringify(error)for proper error serialization in logsSchema Update: Added
skipCalendarSyncTaskCancellationtobookingCancelSchemain zod-utils.tsBooking Reference Consistency: Moved booking reference update (
deleted: true) outside theskipCalendarSyncTaskCancellationconditional block - references are always marked as deleted for data consistency since the external event is already deletedComprehensive Test Suite: Added 16 unit tests covering:
Updates since last revision
calendar.sync.handleEvents.calls- tracks sync invocations by integrationcalendar.sync.handleEvents.events_count- distribution of Cal.com events per synccalendar.sync.cancelBooking.calls/calendar.sync.rescheduleBooking.calls- tracks success/error/skipped statusduration_ms) for cancel and reschedule operations!operators with proper null checks:booking.userIdandbooking.userPrimaryEmailchecked before cancellationbooking.eventTypeIdchecked before reschedulingCalendarSyncService.ts: ChangedgetRegularBookingServiceto use dynamic importgetRoutedUsers.ts: ChangedfindTeamMembersMatchingAttributeLogicto use dynamic import (root cause fix)react-awesome-query-builderfrom being loaded at module evaluation time, fixing the "Super expression must either be null or a function" error in the calendar-subscription webhook endpointMandatory Tasks (DO NOT REMOVE)
How should this be tested?
Human Review Checklist
rescheduleBookingare acceptable:language: "en",metadata: {},timeZone: event.timeZone ?? "UTC"rescheduleUidtriggers a proper reschedule flow (not creating a duplicate booking)allRemainingBookings/cancelSubsequentBookingsis correct - now only cancels single bookings, not recurring seriesCalendarSyncService.tsandgetRoutedUsers.tsdon't introduce any timing/race condition issuesChecklist
Link to Devin run: https://app.devin.ai/sessions/20575cfa274d4721bc8badeda938cc93
Requested by: Volnei Munhoz (volnei@cal.com) (@volnei)