Skip to content

Conversation

@akshayutture-augment
Copy link

Copy link

@greptile-apps greptile-apps bot left a 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.

@akshayutture-augment
Copy link
Author

@greptileai

@greptile-apps
Copy link

greptile-apps bot commented Nov 14, 2025

Greptile Overview

Confidence Score: 1/5

  • This PR contains critical runtime bugs that will cause crashes and prevent core calendar functionality from working correctly
  • Score reflects multiple critical issues: (1) null pointer exception that will crash when checking Google Meet integration, (2) circular logic bugs in Google Calendar service that will prevent calendar updates and deletions from working, and (3) type signature mismatches that may cause runtime errors. While the overall architecture and approach are sound, these bugs will break production functionality.
  • Critical attention needed for packages/core/EventManager.ts (null pointer), packages/app-store/googlecalendar/lib/CalendarService.ts (circular logic bugs), and calendar service files missing proper type signatures

Important Files Changed

File Analysis

Filename Score Overview
packages/core/EventManager.ts 2/5 Refactored to handle multiple destination calendars for collective scheduling. Critical null pointer bug on line 119. Otherwise proper handling of array-based calendar references with DB fallbacks.
packages/app-store/googlecalendar/lib/CalendarService.ts 1/5 Updated for array-based destination calendars. Contains circular logic bugs in updateEvent (line 256) and deleteEvent (line 317) that will prevent proper calendar selection.
packages/app-store/office365calendar/lib/CalendarService.ts 2/5 Updated to use first destination calendar from array. Missing required credentialId parameter in createEvent signature causing type mismatch.
packages/app-store/larkcalendar/lib/CalendarService.ts 2/5 Updated to handle array-based destination calendars by extracting first element. Missing required credentialId parameter in createEvent signature.
packages/features/bookings/lib/handleNewBooking.ts 3/5 Enhanced to collect destination calendars from all team members for collective events. Fixed typo (orginalBookingDurationoriginalBookingDuration). Proper array wrapping for backward compatibility.
packages/core/CalendarManager.ts 4/5 Added externalId parameter to createEvent and properly returns it in result. Fixed typo (organiserorganizer). Clean implementation with proper credential passing.

Sequence Diagram

sequenceDiagram
    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
Loading

Copy link

@greptile-apps greptile-apps bot left a 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

Edit Code Review Agent Settings | Greptile

Comment on lines +118 to +119
const [mainHostDestinationCalendar] = evt.destinationCalendar ?? [];
if (evt.location === MeetLocationType && mainHostDestinationCalendar.integration !== "google_calendar") {
Copy link

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

Suggested change
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.

Comment on lines 254 to +256
const selectedCalendar = externalCalendarId
? externalCalendarId
: event.destinationCalendar?.externalId;
: event.destinationCalendar?.find((cal) => cal.externalId === externalCalendarId)?.externalId;
Copy link

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

Suggested change
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.

Comment on lines +315 to +317
const calendarId = externalCalendarId
? externalCalendarId
: event.destinationCalendar?.find((cal) => cal.externalId === externalCalendarId)?.externalId;
Copy link

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

Suggested change
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> {
Copy link

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

Suggested change
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> {
Copy link

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

Suggested change
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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants