-
Notifications
You must be signed in to change notification settings - Fork 0
fix: handle collective multiple host on destinationCalendar #8
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: enhance-collective-scheduling-foundation
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Your free trial has ended. If you'd like to continue receiving code reviews, you can add a payment method here.
Greptile OverviewConfidence Score: 1/5
Important Files ChangedFile Analysis
Sequence DiagramsequenceDiagram
participant Client
participant handleNewBooking
participant EventManager
participant CalendarManager
participant GoogleCalendar
participant Office365Calendar
participant Database
Client->>handleNewBooking: Create booking request
handleNewBooking->>handleNewBooking: Load users & hosts
alt Collective Event Type
handleNewBooking->>handleNewBooking: Collect destinationCalendar from all team members
handleNewBooking->>handleNewBooking: Build destinationCalendar array
else Single/Round Robin
handleNewBooking->>handleNewBooking: Use organizer's destinationCalendar as array[0]
end
handleNewBooking->>EventManager: create(evt with destinationCalendar[])
loop For each destinationCalendar in array
EventManager->>EventManager: Find credential by credentialId
alt Credential not in memory
EventManager->>Database: Fetch credential by ID
Database-->>EventManager: Return credential
end
EventManager->>CalendarManager: createEvent(credential, event, externalId)
CalendarManager->>GoogleCalendar: createEvent(event, credentialId)
GoogleCalendar->>GoogleCalendar: Find calendar by credentialId
GoogleCalendar-->>CalendarManager: Return event result
CalendarManager-->>EventManager: Return EventResult with externalId & credentialId
end
EventManager-->>handleNewBooking: Return array of created events
handleNewBooking->>Database: Save booking with references
handleNewBooking-->>Client: Return booking confirmation
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
22 files reviewed, 5 comments
| const [mainHostDestinationCalendar] = evt.destinationCalendar ?? []; | ||
| if (evt.location === MeetLocationType && mainHostDestinationCalendar.integration !== "google_calendar") { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
logic: Potential null pointer exception - mainHostDestinationCalendar can be undefined when destinationCalendar is an empty array, causing crash when accessing .integration
| const [mainHostDestinationCalendar] = evt.destinationCalendar ?? []; | |
| if (evt.location === MeetLocationType && mainHostDestinationCalendar.integration !== "google_calendar") { | |
| const [mainHostDestinationCalendar] = evt.destinationCalendar ?? []; | |
| if (evt.location === MeetLocationType && mainHostDestinationCalendar?.integration !== "google_calendar") { |
Prompt To Fix With AI
This is a comment left during a code review.
Path: packages/core/EventManager.ts
Line: 118:119
Comment:
**logic:** Potential null pointer exception - `mainHostDestinationCalendar` can be undefined when `destinationCalendar` is an empty array, causing crash when accessing `.integration`
```suggestion
const [mainHostDestinationCalendar] = evt.destinationCalendar ?? [];
if (evt.location === MeetLocationType && mainHostDestinationCalendar?.integration !== "google_calendar") {
```
How can I resolve this? If you propose a fix, please make it concise.| const selectedCalendar = externalCalendarId | ||
| ? externalCalendarId | ||
| : event.destinationCalendar?.externalId; | ||
| : event.destinationCalendar?.find((cal) => cal.externalId === externalCalendarId)?.externalId; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
logic: Circular logic bug - when externalCalendarId is provided, the fallback searches for a calendar with the same externalCalendarId, which will never match. Should search by credentialId instead or just use the provided value
| const selectedCalendar = externalCalendarId | |
| ? externalCalendarId | |
| : event.destinationCalendar?.externalId; | |
| : event.destinationCalendar?.find((cal) => cal.externalId === externalCalendarId)?.externalId; | |
| const selectedCalendar = externalCalendarId || "primary"; |
Prompt To Fix With AI
This is a comment left during a code review.
Path: packages/app-store/googlecalendar/lib/CalendarService.ts
Line: 254:256
Comment:
**logic:** Circular logic bug - when `externalCalendarId` is provided, the fallback searches for a calendar with the same `externalCalendarId`, which will never match. Should search by `credentialId` instead or just use the provided value
```suggestion
const selectedCalendar = externalCalendarId || "primary";
```
How can I resolve this? If you propose a fix, please make it concise.| const calendarId = externalCalendarId | ||
| ? externalCalendarId | ||
| : event.destinationCalendar?.find((cal) => cal.externalId === externalCalendarId)?.externalId; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
logic: Same circular logic bug as in updateEvent - searching by externalCalendarId in the find condition will never match
| const calendarId = externalCalendarId | |
| ? externalCalendarId | |
| : event.destinationCalendar?.find((cal) => cal.externalId === externalCalendarId)?.externalId; | |
| const calendarId = externalCalendarId | |
| ? externalCalendarId | |
| : event.destinationCalendar?.[0]?.externalId; |
Prompt To Fix With AI
This is a comment left during a code review.
Path: packages/app-store/googlecalendar/lib/CalendarService.ts
Line: 315:317
Comment:
**logic:** Same circular logic bug as in `updateEvent` - searching by `externalCalendarId` in the find condition will never match
```suggestion
const calendarId = externalCalendarId
? externalCalendarId
: event.destinationCalendar?.[0]?.externalId;
```
How can I resolve this? If you propose a fix, please make it concise.| this.log = logger.getChildLogger({ prefix: [`[[lib] ${this.integrationName}`] }); | ||
| } | ||
|
|
||
| async createEvent(event: CalendarEvent): Promise<NewCalendarEventType> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
syntax: Missing credentialId parameter - signature doesn't match the interface Calendar.createEvent(event, credentialId) defined in packages/types/Calendar.d.ts:221
| async createEvent(event: CalendarEvent): Promise<NewCalendarEventType> { | |
| async createEvent(event: CalendarEvent, credentialId: number): Promise<NewCalendarEventType> { |
Prompt To Fix With AI
This is a comment left during a code review.
Path: packages/app-store/office365calendar/lib/CalendarService.ts
Line: 72:72
Comment:
**syntax:** Missing `credentialId` parameter - signature doesn't match the interface `Calendar.createEvent(event, credentialId)` defined in `packages/types/Calendar.d.ts:221`
```suggestion
async createEvent(event: CalendarEvent, credentialId: number): Promise<NewCalendarEventType> {
```
How can I resolve this? If you propose a fix, please make it concise.| }); | ||
| }; | ||
|
|
||
| async createEvent(event: CalendarEvent): Promise<NewCalendarEventType> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
syntax: Missing credentialId parameter - signature doesn't match the interface Calendar.createEvent(event, credentialId) defined in packages/types/Calendar.d.ts:221
| async createEvent(event: CalendarEvent): Promise<NewCalendarEventType> { | |
| async createEvent(event: CalendarEvent, credentialId: number): Promise<NewCalendarEventType> { |
Prompt To Fix With AI
This is a comment left during a code review.
Path: packages/app-store/larkcalendar/lib/CalendarService.ts
Line: 125:125
Comment:
**syntax:** Missing `credentialId` parameter - signature doesn't match the interface `Calendar.createEvent(event, credentialId)` defined in `packages/types/Calendar.d.ts:221`
```suggestion
async createEvent(event: CalendarEvent, credentialId: number): Promise<NewCalendarEventType> {
```
How can I resolve this? If you propose a fix, please make it concise.
Test 4
Replicated from ai-code-review-evaluation/cal.com-greptile#4