Skip to content

fix: CalDAV default calendar not written on booking#28445

Open
Harshithk951 wants to merge 17 commits intocalcom:mainfrom
Harshithk951:fix/caldav-default-calendar-booking-clean
Open

fix: CalDAV default calendar not written on booking#28445
Harshithk951 wants to merge 17 commits intocalcom:mainfrom
Harshithk951:fix/caldav-default-calendar-booking-clean

Conversation

@Harshithk951
Copy link
Copy Markdown
Contributor

@Harshithk951 Harshithk951 commented Mar 15, 2026

What does this PR do?

When "Add to calendar" is set to "Default" in the CalDAV app, no calendar entry was created on booking even though confirmation emails were sent correctly.

Root cause: the filter in BaseCalendarService.createEvent fell through with : true when no destinationCalendar externalId was set, causing createCalendarObject to fire against every discovered calendar collection. Servers like GMX silently drop these writes so no entry is ever created.

Fix: replace : true with calendars.slice(0, 1) — use only the first (primary) calendar when no explicit destination is configured. The explicit-calendar path is unchanged.

Mandatory Tasks

  • 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 API or config changes.
  • I confirm automated tests are in place that prove my fix is effective or that my feature works.

How should this be tested?

  1. Set up CalDAV app with a GMX or any CalDAV provider
  2. Create an event type with "Add to calendar" set to "Default"
  3. Book an appointment
  4. Verify a calendar entry is created in the provider's calendar

Checklist

  • My changes generate no new warnings (Biome + tsc verified)
  • PR is under 500 lines / 10 files
Screen.Recording.2026-03-25.at.8.18.49.PM.mov

Open with Devin

@graphite-app graphite-app bot added the community Created by Linear-GitHub Sync label Mar 15, 2026
@Harshithk951
Copy link
Copy Markdown
Contributor Author

@sahitya-chandra I don't have access to a CalDAV provider (e.g. GMX) to record a
reproduction video locally. The fix is a one-line logic change — replacing : true
with calendars.slice(0, 1) in the default calendar filter. Happy to add a unit test
instead if that would be sufficient for review.

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 1 file

@Harshithk951 Harshithk951 force-pushed the fix/caldav-default-calendar-booking-clean branch from 1dac870 to 7a38fb5 Compare March 16, 2026 13:07
Copy link
Copy Markdown
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't approve this without video evidence...

Will you be able to provide it?

@Harshithk951
Copy link
Copy Markdown
Contributor Author

Hi @sahitya-chandra, yes! I have just updated the PR description with video evidence showing a successful booking flow with a CalDAV calendar. It confirms that the default calendar is now correctly identified and written to. Let me know if you need anything else!

Copy link
Copy Markdown
Contributor

@devin-ai-integration devin-ai-integration bot left a comment

Choose a reason for hiding this comment

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

✅ Devin Review: No Issues Found

Devin Review analyzed this PR and found no potential bugs to report.

View in Devin Review to see 2 additional findings.

Open in Devin Review

@sahitya-chandra sahitya-chandra added ready-for-e2e run-ci Approve CI to run for external contributors labels Apr 3, 2026
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Apr 6, 2026

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: df4d6c06-792b-43a5-99c0-be9b0ca3c14d

📥 Commits

Reviewing files that changed from the base of the PR and between f35bb7e and 846c1e7.

📒 Files selected for processing (1)
  • packages/lib/CalendarService.ts
🚧 Files skipped from review as they are similar to previous changes (1)
  • packages/lib/CalendarService.ts

📝 Walkthrough

Walkthrough

The createEvent method in CalendarService.ts was changed to compute a targetCalendars array up front. If mainHostDestinationCalendar?.externalId is set, targetCalendars contains calendars whose externalId matches that value; otherwise targetCalendars is the first calendar only. The code now throws if targetCalendars is empty. Promise.all iterates over targetCalendars directly, altering which .ics uploads occur and which responses are evaluated for the error check.

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely summarizes the main change: fixing CalDAV default calendar not being written on booking, which directly addresses the bug reported in issue #28385.
Description check ✅ Passed The description is comprehensive and directly related to the changeset, explaining the bug, root cause, fix, testing steps, and includes video evidence of the fix working.
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.

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@packages/lib/CalendarService.ts`:
- Around line 466-481: The code can silently succeed when targetCalendars is
empty; add an explicit guard after computing targetCalendars in the function
containing targetCalendars and createCalendarObject: if targetCalendars.length
=== 0, return or throw an error (consistent with surrounding error handling)
indicating "no target calendars" so you don't proceed to Promise.all; ensure
this uses the same response shape as the function's other error returns (or sets
an appropriate non-ok response) so callers relying on responses.some((r) =>
!r.ok) will see the failure.
🪄 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: 03fb68ba-50cb-442e-83be-00a68c433eef

📥 Commits

Reviewing files that changed from the base of the PR and between facc074 and f35bb7e.

📒 Files selected for processing (1)
  • packages/lib/CalendarService.ts

Comment thread packages/lib/CalendarService.ts
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

community Created by Linear-GitHub Sync ready-for-e2e run-ci Approve CI to run for external contributors size/M

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants