Skip to content

fix: support @cal.diy iCalUIDs in calendar sync#29581

Open
Prateet-Github wants to merge 1 commit into
calcom:mainfrom
Prateet-Github:fix/calendar-sync-icaluid
Open

fix: support @cal.diy iCalUIDs in calendar sync#29581
Prateet-Github wants to merge 1 commit into
calcom:mainfrom
Prateet-Github:fix/calendar-sync-icaluid

Conversation

@Prateet-Github

Copy link
Copy Markdown
Contributor

What does this PR do?

Fixes #29575

Calendar subscription sync currently only processes events whose iCalUID ends with @cal.com.

In default Cal.diy deployments, booking iCalUIDs are generated using the configured app name and commonly use the @Cal.diy suffix. Because of the strict @cal.com filter, valid Cal.diy booking events were ignored during calendar subscription sync and did not trigger booking cancellation or rescheduling workflows.

This PR updates the calendar sync filter to recognize both:

  • @cal.com
  • @cal.diy

while continuing to ignore external calendar events.

Additionally, regression tests were added to verify support for:

  • Cal.diy iCalUIDs
  • Legacy @cal.com iCalUIDs
  • Mixed-case @CAL.DIY iCalUIDs

Visual Demo (For contributors especially)

N/A – backend-only change with no UI impact.

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 if this PR makes changes that would require a documentation change. N/A
  • I confirm automated tests are in place that prove my fix is effective or that my feature works.

How should this be tested?

Run:

yarn test packages/features/calendar-subscription/lib/sync/tests/CalendarSyncService.test.ts

Verify all tests pass successfully.

Environment Variables

No additional environment variables are required.

Minimal Test Data

Valid iCalUID examples:

Invalid/external example:

Expected Behavior

Events with:

  • @cal.com
  • @cal.diy
  • mixed-case variants such as @CAL.DIY

should be processed by CalendarSyncService.

Events from external providers should continue to be ignored.

Checklist

  • I have read the contributing guide.
  • My code follows the style guidelines of this project.
  • I have checked that my changes generate no new warnings.
  • This PR is small and focused.

@github-actions

Copy link
Copy Markdown
Contributor

Welcome to Cal.diy, @Prateet-Github! Thanks for opening this pull request.

A few things to keep in mind:

  • This is Cal.diy, not Cal.com. Cal.diy is a community-driven, fully open-source fork of Cal.com licensed under MIT. Your changes here will be part of Cal.diy — they will not be deployed to the Cal.com production app.
  • Please review our Contributing Guidelines if you haven't already.
  • Make sure your PR title follows the Conventional Commits format.

A maintainer will review your PR soon. Thanks for contributing!

@github-actions github-actions Bot added the 🐛 bug Something isn't working label Jun 15, 2026
@coderabbitai

coderabbitai Bot commented Jun 15, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 03abc3ad-b3f5-423a-b1e0-b88d2b0607e8

📥 Commits

Reviewing files that changed from the base of the PR and between 2aed2d8 and 4fac205.

📒 Files selected for processing (2)
  • packages/features/calendar-subscription/lib/sync/CalendarSyncService.ts
  • packages/features/calendar-subscription/lib/sync/__tests__/CalendarSyncService.test.ts
✅ Files skipped from review due to trivial changes (1)
  • packages/features/calendar-subscription/lib/sync/tests/CalendarSyncService.test.ts
🚧 Files skipped from review as they are similar to previous changes (1)
  • packages/features/calendar-subscription/lib/sync/CalendarSyncService.ts

📝 Walkthrough

Walkthrough

CalendarSyncService.handleEvents previously identified Cal.com calendar events by checking whether iCalUID (lowercased) ends with @cal.com. The filter is now extended to also accept @cal.diy as a valid suffix, using a logical OR check after lowercasing the iCalUID. Test fixtures in CalendarSyncService.test.ts are updated to replace @cal.com/@CAL.COM domain suffixes with @Cal.diy/@CAL.DIY, covering both the standard and mixed-case matching scenarios.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely describes the main change: adding support for @cal.diy iCalUIDs in calendar sync.
Description check ✅ Passed The description is comprehensive and directly related to the changeset, explaining the problem, solution, testing approach, and checklist items.
Linked Issues check ✅ Passed The code changes fully implement the requirements from issue #29575: the iCalUID filter now accepts both @cal.com and @cal.diy suffixes, includes case-insensitive matching, and maintains backward compatibility.
Out of Scope Changes check ✅ Passed All changes are directly in scope: CalendarSyncService.ts updates the filter logic as required, and CalendarSyncService.test.ts adds regression tests to verify the fix.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🧹 Nitpick comments (1)
packages/features/calendar-subscription/lib/sync/__tests__/CalendarSyncService.test.ts (1)

160-208: ⚡ Quick win

Add one explicit legacy @cal.com regression test to protect backward compatibility.

Current updates cover @cal.diy (including mixed case), but there is no direct assertion that legacy @cal.com UIDs are still processed. Adding one focused test here would lock in objective (2) from this PR.

Suggested test addition
   describe("handleEvents", () => {
+    test("should still process legacy `@cal.com` events", async () => {
+      const legacyCalComEvent: CalendarSubscriptionEventItem = {
+        ...mockCalComEvent,
+        iCalUID: "legacy-booking-uid@cal.com",
+      };
+
+      mockBookingRepository.findBookingByUidWithEventType = vi.fn().mockResolvedValue({
+        ...mockBooking,
+        uid: "legacy-booking-uid",
+      });
+
+      await service.handleEvents(mockSelectedCalendar, [legacyCalComEvent]);
+
+      expect(mockBookingRepository.findBookingByUidWithEventType).toHaveBeenCalledWith({
+        bookingUid: "legacy-booking-uid",
+      });
+    });
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In
`@packages/features/calendar-subscription/lib/sync/__tests__/CalendarSyncService.test.ts`
around lines 160 - 208, The test suite for handleEvents covers `@cal.diy` domain
events and mixed case variants, but lacks coverage for legacy `@cal.com`
domain-based iCalUIDs. Add a new test case in the handleEvents describe block
(similar to the "should handle mixed case iCalUID" test) that creates a
CalendarSubscriptionEventItem with an iCalUID using the legacy `@cal.com` domain
(e.g., "test-booking-uid@cal.com"), mocks the booking repository to return a
valid booking, calls service.handleEvents with this event, and asserts that
mockBookingRepository.findBookingByUidWithEventType is called with the correctly
extracted booking UID to ensure backward compatibility is maintained.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@packages/features/calendar-subscription/lib/sync/CalendarSyncService.ts`:
- Around line 45-49: The inline comment on Line 45 in the CalendarSyncService
filter states "only process cal.com calendar events" but the actual code filters
for both "`@cal.com`" and "`@cal.diy`" domains on Line 48, making the comment stale
and misleading. Either remove the comment entirely since the filter logic is
self-explanatory, or replace it with a "why" comment that explains the business
reason for filtering by these specific calendar domains (e.g., "filter to only
internal cal.com and cal.diy calendar events"). Avoid "what" comments that just
restate the code logic.

---

Nitpick comments:
In
`@packages/features/calendar-subscription/lib/sync/__tests__/CalendarSyncService.test.ts`:
- Around line 160-208: The test suite for handleEvents covers `@cal.diy` domain
events and mixed case variants, but lacks coverage for legacy `@cal.com`
domain-based iCalUIDs. Add a new test case in the handleEvents describe block
(similar to the "should handle mixed case iCalUID" test) that creates a
CalendarSubscriptionEventItem with an iCalUID using the legacy `@cal.com` domain
(e.g., "test-booking-uid@cal.com"), mocks the booking repository to return a
valid booking, calls service.handleEvents with this event, and asserts that
mockBookingRepository.findBookingByUidWithEventType is called with the correctly
extracted booking UID to ensure backward compatibility is maintained.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: ba0cc1cd-aeb1-4ca8-bfa6-3d8990789563

📥 Commits

Reviewing files that changed from the base of the PR and between dcd0da8 and 2aed2d8.

📒 Files selected for processing (2)
  • packages/features/calendar-subscription/lib/sync/CalendarSyncService.ts
  • packages/features/calendar-subscription/lib/sync/__tests__/CalendarSyncService.test.ts

Comment thread packages/features/calendar-subscription/lib/sync/CalendarSyncService.ts Outdated
@kartik-212004

Copy link
Copy Markdown
Member

please fix the coderabbit suggestion above , making it draft until then

@kartik-212004 kartik-212004 marked this pull request as draft June 15, 2026 18:30
@Prateet-Github Prateet-Github force-pushed the fix/calendar-sync-icaluid branch from 2aed2d8 to 4fac205 Compare June 15, 2026 18:57
@Prateet-Github

Copy link
Copy Markdown
Contributor Author

please fix the coderabbit suggestion above , making it draft until then

Fixed the CodeRabbit suggestion by removing the outdated comment above the iCalUID filter and pushed the update. Thanks for the review!

@CLAassistant

CLAassistant commented Jun 16, 2026

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

@Prateet-Github Prateet-Github marked this pull request as ready for review June 17, 2026 07:32
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/S

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Calendar subscription sync ignores Cal.diy iCalUIDs

3 participants