{"record":{"id":"301a6f4a50d3004e","repo":"calcom/cal.diy","slug":"event-not-found","errorCode":null,"errorMessage":"Event not found","messagePattern":"Event not found","errorType":"http","errorClass":"NotFoundException","httpStatus":404,"severity":"warning","filePath":"apps/api/v2/src/modules/cal-unified-calendars/services/google-calendar.service.ts","lineNumber":290,"sourceCode":"    } catch (error) {\n      if (error instanceof HttpException) throw error;\n      throw this.mapGoogleApiError(error, \"Failed to create calendar event\");\n    }\n  }\n\n  private async getEventWithClient(\n    calendar: calendar_v3.Calendar,\n    calendarId: string,\n    eventId: string\n  ): Promise<GoogleCalendarEventResponse> {\n    const effectiveCalendarId = calendarId || \"primary\";\n    try {\n      const event = await calendar.events.get({\n        calendarId: effectiveCalendarId,\n        eventId,\n      });\n      if (!event.data) {\n        throw new NotFoundException(\"Event not found\");\n      }\n      return event.data as GoogleCalendarEventResponse;\n    } catch (error) {\n      if (error instanceof HttpException) throw error;\n      throw this.mapGoogleApiError(error, \"Failed to retrieve event details\");\n    }\n  }\n\n  private async updateEventWithClient(\n    calendar: calendar_v3.Calendar,\n    calendarId: string,\n    eventId: string,\n    updateData: UpdateUnifiedCalendarEventInput\n  ): Promise<GoogleCalendarEventResponse> {\n    const effectiveCalendarId = calendarId || \"primary\";\n    const updatePayload = new GoogleCalendarEventInputPipe().transform(updateData);\n    try {\n      const event = await calendar.events.patch({","sourceCodeStart":272,"sourceCodeEnd":308,"githubUrl":"https://github.com/calcom/cal.diy/blob/176037d0afbe572f870a3c702985e7cd83fe6c0c/apps/api/v2/src/modules/cal-unified-calendars/services/google-calendar.service.ts#L272-L308","documentation":"Thrown by getEventWithClient when calendar.events.get resolves with no data — the event id does not exist in the given calendar. Returns HTTP 404 via NotFoundException. The catch block also maps any Google 404 to this same message, so it covers both the no-data guard and the API-level not-found.","triggerScenarios":"Calling GET /v2/calendars/connections/{id}/events/{eventId} with an eventId that was deleted, never existed, or belongs to a different calendarId. Also when the event id has a leading whitespace or encoding issue.","commonSituations":"Event was deleted out of band (directly in Google Calendar UI); client cached an old event id; calendarId/eventId mix-up; recurring event instance id vs master id confusion.","solutions":["Verify the eventId still exists via Google Calendar UI or a list call.","If deleted, remove the corresponding booking reference and stop polling.","URL-encode the eventId (Google ids can contain characters that need encoding).","For recurring events, use the instance id returned by the events.list, not the series master id, when fetching a specific occurrence."],"exampleFix":"// before\nconst event = await googleCalendarService.getEventByConnectionId(userId, credId, calId, eventId);\n\n// after\ntry {\n  const event = await googleCalendarService.getEventByConnectionId(userId, credId, calId, eventId);\n} catch (e) {\n  if (e instanceof NotFoundException) {\n    // sync local cache: mark booking reference as cancelled\n    await bookingReferencesRepository.markRemoved(eventUid);\n    return null;\n  }\n  throw e;\n}","handlingStrategy":"try-catch","validationCode":"// Pre-flight: confirm event exists via a list call before fetching directly.\nasync function eventExists(calendar: calendar_v3.Calendar, calendarId: string, eventId: string): Promise<boolean> {\n  try {\n    await calendar.events.get({ calendarId, eventId });\n    return true;\n  } catch {\n    return false;\n  }\n}","typeGuard":"function isGoogleEventFound(r: { data?: unknown }): r is { data: Record<string, unknown> } {\n  return Boolean(r.data && typeof r.data === 'object' && 'id' in (r.data as object));\n}","tryCatchPattern":"try {\n  return await googleCalendarService.getEventByConnectionId(userId, credId, calId, evId);\n} catch (e) {\n  if (e instanceof NotFoundException) {\n    // reconcile local state — the event is gone\n    await bookingReferencesRepository.markRemoved(eventUid);\n    return null;\n  }\n  throw e;\n}","preventionTips":["URL-encode the eventId when building the request path.","For recurring events, use the instance id returned by list, not the master id.","Treat 404 as a signal to clean up local references rather than a hard failure."],"tags":["google-calendar","google-api","event-get","nestjs","not-found"],"backgroundTag":null,"analyzedSha":"176037d0afbe572f870a3c702985e7cd83fe6c0c","analyzedAt":"2026-08-12T19:12:41.464Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}