Skip to content

Comments

fix: fetching calendar links for seated events#24265

Draft
dhairyashiil wants to merge 6 commits intocalcom:mainfrom
dhairyashiil:fix/fetching-calendar-links-for-seated-events
Draft

fix: fetching calendar links for seated events#24265
dhairyashiil wants to merge 6 commits intocalcom:mainfrom
dhairyashiil:fix/fetching-calendar-links-for-seated-events

Conversation

@dhairyashiil
Copy link
Member

@dhairyashiil dhairyashiil commented Oct 3, 2025

What does this PR do?

Working Video:

Screen.Recording.2025-10-04.at.9.55.23.PM.mov

@vercel
Copy link

vercel bot commented Oct 3, 2025

@dhairyashiil is attempting to deploy a commit to the cal Team on Vercel.

A member of the Team first needs to authorize it.

@github-actions github-actions bot added api area: API, enterprise API, access token, OAuth platform Anything related to our platform plan reactive⚡︎ 🐛 bug Something isn't working labels Oct 3, 2025
@keithwillcode keithwillcode added the community-interns The team responsible for reviewing, testing and shipping low/medium community PRs label Oct 3, 2025
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Oct 3, 2025

Walkthrough

Service now fetches bookings using a new repository method getByUidForCalendarLinks(uid) that returns start/end times, location, title, metadata, responses, eventTypeId and nested attendees.bookingSeat.data. getCalendarLinks was updated to compute bookingData from the first attendee’s bookingSeat.data when present, otherwise from booking.responses; dynamic titles, attendee name, and booking fields now read from bookingData. Types changed: responses and metadata are Prisma.JsonValue, and attendees?: Array<{ bookingSeat?: { data: Prisma.JsonValue } | null }> was added. Control flow and ICS generation logic remain.

Pre-merge checks and finishing touches

✅ Passed checks (5 passed)
Check name Status Explanation
Title Check ✅ Passed The title clearly and concisely describes the primary change in this PR by stating that it fixes the issue of fetching calendar links for seated events, directly matching the bug being addressed. It avoids unnecessary detail or noise and uses straightforward wording that teammates can quickly understand when scanning history. This phrasing accurately reflects the main purpose of the changeset.
Linked Issues Check ✅ Passed The PR adds a new repository method to fetch seat-specific booking data, updates the service to use this method, and adjusts getCalendarLinks to derive bookingData from attendee seat data, thereby preventing the 500 error described. These changes directly fulfill the objectives of issues #24218 and CAL-6503 by handling seated events correctly and resolving the server error. All core requirements from the linked issues are implemented.
Out of Scope Changes Check ✅ Passed All modifications are confined to the getCalendarLinks logic, related type definitions, and the new repository method for fetching seat data, which directly address the seated-event calendar link bug. No unrelated files or features have been altered. There are no out-of-scope changes present.
Description Check ✅ Passed The description lists the relevant issue numbers and provides a working video link, directly relating to the bug fix for calendar link fetching on seated events. It contextualizes the problem being solved without deviating from the changeset. This content is clearly on-topic and satisfies the lenient description criteria.
Docstring Coverage ✅ Passed No functions found in the changes. Docstring coverage check skipped.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

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.

@dhairyashiil dhairyashiil marked this pull request as ready for review October 4, 2025 16:27
@dhairyashiil dhairyashiil requested review from a team as code owners October 4, 2025 16:27
@graphite-app graphite-app bot added the community Created by Linear-GitHub Sync label Oct 4, 2025
@graphite-app graphite-app bot requested review from a team and removed request for a team October 4, 2025 16:27
@dosubot dosubot bot added the bookings area: bookings, availability, timezones, double booking label Oct 4, 2025
Copy link
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: 2

📜 Review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Disabled knowledge base sources:

  • Linear integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between 654a865 and 1d39e8e.

📒 Files selected for processing (2)
  • apps/api/v2/src/ee/bookings/2024-08-13/services/bookings.service.ts (1 hunks)
  • packages/features/bookings/lib/getCalendarLinks.ts (3 hunks)
🧰 Additional context used
📓 Path-based instructions (4)
**/*.{service,repository}.ts

📄 CodeRabbit inference engine (.cursor/rules/review.mdc)

Avoid dot-suffixes like .service.ts or .repository.ts for new files; reserve .test.ts, .spec.ts, .types.ts for their specific purposes

Files:

  • apps/api/v2/src/ee/bookings/2024-08-13/services/bookings.service.ts
**/*.ts

📄 CodeRabbit inference engine (.cursor/rules/review.mdc)

**/*.ts: For Prisma queries, only select data you need; never use include, always use select
Ensure the credential.key field is never returned from tRPC endpoints or APIs

Files:

  • apps/api/v2/src/ee/bookings/2024-08-13/services/bookings.service.ts
  • packages/features/bookings/lib/getCalendarLinks.ts
**/*.{ts,tsx}

📄 CodeRabbit inference engine (.cursor/rules/review.mdc)

Flag excessive Day.js use in performance-critical code; prefer native Date or Day.js .utc() in hot paths like loops

Files:

  • apps/api/v2/src/ee/bookings/2024-08-13/services/bookings.service.ts
  • packages/features/bookings/lib/getCalendarLinks.ts
**/*.{ts,tsx,js,jsx}

⚙️ CodeRabbit configuration file

Flag default exports and encourage named exports. Named exports provide better tree-shaking, easier refactoring, and clearer imports. Exempt main components like pages, layouts, and components that serve as the primary export of a module.

Files:

  • apps/api/v2/src/ee/bookings/2024-08-13/services/bookings.service.ts
  • packages/features/bookings/lib/getCalendarLinks.ts
🧠 Learnings (3)
📓 Common learnings
Learnt from: supalarry
PR: calcom/cal.com#23514
File: apps/api/v2/src/ee/bookings/2024-08-13/services/bookings.service.ts:579-582
Timestamp: 2025-09-03T11:54:05.409Z
Learning: In calcom/cal.com bookings repository methods, when Prisma include uses `eventType: true`, all eventType fields including seatsShowAttendees are automatically included in the selection. Explicit field selection is not required when using `true` for nested relations.
Learnt from: supalarry
PR: calcom/cal.com#23514
File: apps/api/v2/src/ee/bookings/2024-08-13/services/bookings.service.ts:579-582
Timestamp: 2025-09-03T11:54:05.409Z
Learning: In calcom/cal.com bookings repository methods, when Prisma include uses `eventType: true`, all eventType fields including seatsShowAttendees are automatically included in the selection. Explicit field selection is not required when using `true` for nested relations.
Learnt from: supalarry
PR: calcom/cal.com#23514
File: apps/api/v2/src/ee/bookings/2024-08-13/services/bookings.service.ts:579-582
Timestamp: 2025-09-03T11:54:05.409Z
Learning: In calcom/cal.com bookings repository methods, when Prisma select uses `eventType: true`, all eventType fields including seatsShowAttendees are automatically included in the selection. Explicit field selection is not required when using `true` for nested relations.
📚 Learning: 2025-08-21T13:44:06.805Z
Learnt from: supalarry
PR: calcom/cal.com#23217
File: apps/api/v2/src/ee/event-types/event-types_2024_06_14/services/output-event-types.service.ts:93-94
Timestamp: 2025-08-21T13:44:06.805Z
Learning: In apps/api/v2/src/ee/event-types/event-types_2024_06_14/event-types.repository.ts, repository functions that use explicit Prisma select clauses (like getEventTypeWithSeats) are used for specific purposes and don't need to include all EventType fields like bookingRequiresAuthentication. These methods don't feed into the general OutputEventTypesService_2024_06_14 flow.

Applied to files:

  • apps/api/v2/src/ee/bookings/2024-08-13/services/bookings.service.ts
📚 Learning: 2025-09-03T11:54:05.409Z
Learnt from: supalarry
PR: calcom/cal.com#23514
File: apps/api/v2/src/ee/bookings/2024-08-13/services/bookings.service.ts:579-582
Timestamp: 2025-09-03T11:54:05.409Z
Learning: In calcom/cal.com bookings repository methods, when Prisma select uses `eventType: true`, all eventType fields including seatsShowAttendees are automatically included in the selection. Explicit field selection is not required when using `true` for nested relations.

Applied to files:

  • packages/features/bookings/lib/getCalendarLinks.ts
🧬 Code graph analysis (1)
packages/features/bookings/lib/getCalendarLinks.ts (1)
packages/features/eventtypes/lib/eventNaming.ts (1)
  • nameObjectSchema (7-10)
⏰ Context from checks skipped due to timeout of 180000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
  • GitHub Check: Install dependencies / Yarn install & cache
  • GitHub Check: Codacy Static Code Analysis
🔇 Additional comments (3)
packages/features/bookings/lib/getCalendarLinks.ts (2)

173-186: LGTM! Data source unification improves consistency.

The changes correctly unify the data source for dynamic titles, attendee names, and booking fields by using bookingData. This ensures consistency across calendar link generation and properly supports seated events.


171-171: Ensure correct attendee selection for calendar link data

The code in packages/features/bookings/lib/getCalendarLinks.ts line 171 uses booking.attendees[0].bookingSeat.data when present. For seated events with multiple attendees, confirm that the first attendee always provides the right calendar link data—or adjust this to pick the intended attendee’s bookingSeat.

apps/api/v2/src/ee/bookings/2024-08-13/services/bookings.service.ts (1)

1112-1114: LGTM — bookingSeat is included but will be null for non-seated events, so existing calendar links remain unaffected.

devin-ai-integration bot added a commit that referenced this pull request Oct 4, 2025
…methods

- Convert getByUidWithAttendeesWithBookingSeatAndUserAndEvent to use select
- Convert getByIdWithAttendeesWithBookingSeatAndUserAndEvent to use select
- Add type casting for responses and metadata fields
- Select only necessary fields from user, attendees, and bookingSeat relations

Addresses code review comment in PR #24265

Co-Authored-By: Dhairyashil Shinde <dhairyashil10101010@gmail.com>
@pull-request-size pull-request-size bot added size/M and removed size/S labels Oct 5, 2025
Copy link
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

📜 Review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Disabled knowledge base sources:

  • Linear integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between 1d39e8e and 630e1ea.

📒 Files selected for processing (3)
  • apps/api/v2/src/ee/bookings/2024-08-13/bookings.repository.ts (1 hunks)
  • apps/api/v2/src/ee/bookings/2024-08-13/services/bookings.service.ts (1 hunks)
  • packages/features/bookings/lib/getCalendarLinks.ts (3 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • apps/api/v2/src/ee/bookings/2024-08-13/services/bookings.service.ts
🧰 Additional context used
📓 Path-based instructions (4)
**/*.{service,repository}.ts

📄 CodeRabbit inference engine (.cursor/rules/review.mdc)

Avoid dot-suffixes like .service.ts or .repository.ts for new files; reserve .test.ts, .spec.ts, .types.ts for their specific purposes

Files:

  • apps/api/v2/src/ee/bookings/2024-08-13/bookings.repository.ts
**/*.ts

📄 CodeRabbit inference engine (.cursor/rules/review.mdc)

**/*.ts: For Prisma queries, only select data you need; never use include, always use select
Ensure the credential.key field is never returned from tRPC endpoints or APIs

Files:

  • apps/api/v2/src/ee/bookings/2024-08-13/bookings.repository.ts
  • packages/features/bookings/lib/getCalendarLinks.ts
**/*.{ts,tsx}

📄 CodeRabbit inference engine (.cursor/rules/review.mdc)

Flag excessive Day.js use in performance-critical code; prefer native Date or Day.js .utc() in hot paths like loops

Files:

  • apps/api/v2/src/ee/bookings/2024-08-13/bookings.repository.ts
  • packages/features/bookings/lib/getCalendarLinks.ts
**/*.{ts,tsx,js,jsx}

⚙️ CodeRabbit configuration file

Flag default exports and encourage named exports. Named exports provide better tree-shaking, easier refactoring, and clearer imports. Exempt main components like pages, layouts, and components that serve as the primary export of a module.

Files:

  • apps/api/v2/src/ee/bookings/2024-08-13/bookings.repository.ts
  • packages/features/bookings/lib/getCalendarLinks.ts
🧠 Learnings (3)
📓 Common learnings
Learnt from: supalarry
PR: calcom/cal.com#23217
File: apps/api/v2/src/ee/event-types/event-types_2024_06_14/services/output-event-types.service.ts:93-94
Timestamp: 2025-08-21T13:44:06.805Z
Learning: In apps/api/v2/src/ee/event-types/event-types_2024_06_14/event-types.repository.ts, repository functions that use explicit Prisma select clauses (like getEventTypeWithSeats) are used for specific purposes and don't need to include all EventType fields like bookingRequiresAuthentication. These methods don't feed into the general OutputEventTypesService_2024_06_14 flow.
📚 Learning: 2025-08-19T09:47:49.478Z
Learnt from: eunjae-lee
PR: calcom/cal.com#23166
File: packages/prisma/migrations/20250818151914_routing_form_response_denormalized_backfill2/migration.sql:65-66
Timestamp: 2025-08-19T09:47:49.478Z
Learning: The Booking table has a unique constraint and index on the uid column (defined as `uid String unique` in schema.prisma), so JOINs on Booking.uid have optimal performance and don't require additional indexing.

Applied to files:

  • apps/api/v2/src/ee/bookings/2024-08-13/bookings.repository.ts
📚 Learning: 2025-09-03T11:54:05.409Z
Learnt from: supalarry
PR: calcom/cal.com#23514
File: apps/api/v2/src/ee/bookings/2024-08-13/services/bookings.service.ts:579-582
Timestamp: 2025-09-03T11:54:05.409Z
Learning: In calcom/cal.com bookings repository methods, when Prisma select uses `eventType: true`, all eventType fields including seatsShowAttendees are automatically included in the selection. Explicit field selection is not required when using `true` for nested relations.

Applied to files:

  • packages/features/bookings/lib/getCalendarLinks.ts
🧬 Code graph analysis (1)
packages/features/bookings/lib/getCalendarLinks.ts (1)
packages/features/eventtypes/lib/eventNaming.ts (1)
  • nameObjectSchema (7-10)
⏰ Context from checks skipped due to timeout of 180000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (3)
  • GitHub Check: Type check / check-types
  • GitHub Check: Linters / lint
  • GitHub Check: Codacy Static Code Analysis
🔇 Additional comments (5)
packages/features/bookings/lib/getCalendarLinks.ts (5)

10-10: LGTM!

The Prisma type import is necessary for the updated type signatures.


148-150: LGTM!

The type changes from Prisma.JsonObject to Prisma.JsonValue for responses and metadata improve flexibility, and the addition of the attendees array with nested bookingSeat.data correctly supports the new data source for seated events.


171-176: Previous type safety concern has been addressed.

The runtime type validation correctly prevents errors when rawBookingData is null, primitive, or an array. This implementation matches the previously suggested fix.


178-179: LGTM!

The usage of bookingData instead of booking.responses is consistent throughout the function, correctly implementing the unified data source for both regular and seated events.

Also applies to: 183-183, 188-188


171-176: No changes needed. getCalendarLinks intentionally uses the first attendee (the booking host) to source bookingSeat.data for personalization; existing tests confirm this behavior.

}

async getByUidForCalendarLinks(uid: string) {
return this.dbRead.prisma.booking.findUnique({
Copy link
Member Author

@dhairyashiil dhairyashiil Oct 5, 2025

Choose a reason for hiding this comment

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

Created this separate function because it is faster and more efficient than getByUidWithAttendeesAndUserAndEvent, as it only fetches the fields needed for calendar links, reducing database load.

Also, didn’t want to modify getByUidWithAttendeesAndUserAndEvent as per CoderabbitAI’s comment, since this function is used in other parts of the codebase as well.

Let me know, if this works and other things I should update

Copy link
Contributor

@pallava-joshi pallava-joshi left a comment

Choose a reason for hiding this comment

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

type checks are failing. also implement code rabbit suggestions.

@pallava-joshi pallava-joshi marked this pull request as draft October 13, 2025 06:02
Copy link
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.

1 issue found across 4 files

Prompt for AI agents (all 1 issues)

Understand the root cause of the following 1 issues and fix them.


<file name="apps/api/v2/src/ee/bookings/2024-08-13/services/bookings.service.ts">

<violation number="1" location="apps/api/v2/src/ee/bookings/2024-08-13/services/bookings.service.ts:1112">
getByUidForCalendarLinks strips eventTypeId, so this new call always fails the eventType check and the endpoint now throws for every booking.</violation>
</file>

React with 👍 or 👎 to teach cubic. Mention @cubic-dev-ai to give feedback, ask questions, or re-run the review.

Copy link
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

@dhairyashiil dhairyashiil marked this pull request as ready for review October 18, 2025 19:12
Copy link
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.

1 issue found across 4 files

Prompt for AI agents (all 1 issues)

Understand the root cause of the following 1 issues and fix them.


<file name="packages/features/bookings/lib/getCalendarLinks.ts">

<violation number="1" location="packages/features/bookings/lib/getCalendarLinks.ts:171">
When pulling seated booking data we must read bookingSeat.data.responses; using the whole object leaves dynamic titles/attendee fields undefined and breaks calendar link personalization.</violation>
</file>

React with 👍 or 👎 to teach cubic. Mention @cubic-dev-ai to give feedback, ask questions, or re-run the review.


if (eventType.isDynamic && booking.responses.title) {
evtName = booking.responses.title as string;
const rawBookingData = booking.attendees?.[0]?.bookingSeat?.data || booking.responses;
Copy link
Contributor

@cubic-dev-ai cubic-dev-ai bot Oct 18, 2025

Choose a reason for hiding this comment

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

When pulling seated booking data we must read bookingSeat.data.responses; using the whole object leaves dynamic titles/attendee fields undefined and breaks calendar link personalization.

Prompt for AI agents
Address the following comment on packages/features/bookings/lib/getCalendarLinks.ts at line 171:

<comment>When pulling seated booking data we must read bookingSeat.data.responses; using the whole object leaves dynamic titles/attendee fields undefined and breaks calendar link personalization.</comment>

<file context>
@@ -167,16 +168,24 @@ export const getCalendarLinks = ({
 
-  if (eventType.isDynamic &amp;&amp; booking.responses.title) {
-    evtName = booking.responses.title as string;
+  const rawBookingData = booking.attendees?.[0]?.bookingSeat?.data || booking.responses;
+  const bookingData = (
+    rawBookingData &amp;&amp; typeof rawBookingData === &quot;object&quot; &amp;&amp; !Array.isArray(rawBookingData)
</file context>
Suggested change
const rawBookingData = booking.attendees?.[0]?.bookingSeat?.data || booking.responses;
const rawBookingData = (booking.attendees?.[0]?.bookingSeat?.data as Prisma.JsonObject | undefined)?.responses || booking.responses;
Fix with Cubic

@dhairyashiil dhairyashiil marked this pull request as draft October 18, 2025 19:47
@github-actions
Copy link
Contributor

This PR has been marked as stale due to inactivity. If you're still working on it or need any help, please let us know or update the PR to keep it active.

@github-actions github-actions bot added the Stale label Oct 28, 2025
@github-actions github-actions bot removed the Stale label Oct 29, 2025
Copy link
Contributor

@Ryukemeister Ryukemeister left a comment

Choose a reason for hiding this comment

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

@dhairyashiil thanks for creating the PR, had some questions:

  1. in the PR I can see you've attached a working video but what i'm curious about is why was it not working before? just wanna what were we doing here previously?
  2. can you also update the e2e tests for calendar links we have here apps/api/v2/src/ee/bookings/2024-08-13/controllers/e2e/calendar-links.e2e-spec.ts

@devin-ai-integration devin-ai-integration bot added the Medium priority Created by Linear-GitHub Sync label Jan 19, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

api area: API, enterprise API, access token, OAuth bookings area: bookings, availability, timezones, double booking 🐛 bug Something isn't working community Created by Linear-GitHub Sync community-interns The team responsible for reviewing, testing and shipping low/medium community PRs Medium priority Created by Linear-GitHub Sync platform Anything related to our platform plan reactive⚡︎ size/M

Projects

None yet

Development

Successfully merging this pull request may close these issues.

fix: fetching calendar-links for seated events

4 participants