{"record":{"id":"626f722efac1d991","repo":"calcom/cal.diy","slug":"no-calendar-id","errorCode":null,"errorMessage":"no calendar id","messagePattern":"no calendar id","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/app-store/feishucalendar/lib/CalendarService.ts","lineNumber":144,"sourceCode":"      headers: {\n        Authorization: `Bearer ${accessToken}`,\n        \"Content-Type\": \"application/json\",\n        ...init?.headers,\n      },\n      ...init,\n    });\n  };\n\n  async createEvent(event: CalendarServiceEvent, credentialId: number): Promise<NewCalendarEventType> {\n    let eventId = \"\";\n    let eventRespData;\n    const mainHostDestinationCalendar = event.destinationCalendar\n      ? event.destinationCalendar.find((cal) => cal.credentialId === this.credential.id) ??\n        event.destinationCalendar[0]\n      : undefined;\n    const calendarId = mainHostDestinationCalendar?.externalId;\n    if (!calendarId) {\n      throw new Error(\"no calendar id\");\n    }\n    try {\n      const eventResponse = await this.fetcher(`/calendar/v4/calendars/${calendarId}/events/create_event`, {\n        method: \"POST\",\n        body: JSON.stringify(this.translateEvent(event)),\n      });\n      eventRespData = await handleFeishuError<CreateEventResp>(eventResponse, this.log);\n      eventId = eventRespData.data.event.event_id as string;\n    } catch (error) {\n      this.log.error(error);\n      throw error;\n    }\n\n    try {\n      await this.createAttendees(event, eventId, credentialId);\n      return {\n        ...eventRespData,\n        uid: eventRespData.data.event.event_id as string,","sourceCodeStart":126,"sourceCodeEnd":162,"githubUrl":"https://github.com/calcom/cal.diy/blob/176037d0afbe572f870a3c702985e7cd83fe6c0c/packages/app-store/feishucalendar/lib/CalendarService.ts#L126-L162","documentation":"Thrown by FeishuCalendarService.createEvent when no calendarId can be resolved. The handler looks up the host's destinationCalendar (matching by credentialId, falling back to the first entry) and reads its externalId; if the user has no destinationCalendar or its externalId is empty, the event cannot be created in Feishu.","triggerScenarios":"Booking created for a user whose Feishu calendar integration is connected but who has no destinationCalendar row (externalId) set; destinationCalendar exists but externalId is empty; the credentialId in destinationCalendar does not match any connected calendar.","commonSituations":"User connected Feishu but never selected a primary calendar; event.destinationCalendar array is undefined for managed/teams bookings; destinationCalendar.externalId got cleared by a sync bug.","solutions":["Ensure each host with a Feishu credential has a destinationCalendar with a non-empty externalId (the Feishu primary calendar id).","Re-trigger the calendar selection / destinationCalendar setup for the affected user.","Verify the credentialId used in destinationCalendar matches an installed Feishu credential.","Surface a user-facing message instead of throwing when destinationCalendar is absent."],"exampleFix":"// before\nconst calendarId = mainHostDestinationCalendar?.externalId;\nif (!calendarId) {\n  throw new Error(\"no calendar id\");\n}\n\n// after - descriptive, actionable\nif (!calendarId) {\n  throw new Error(`No Feishu calendar id resolved for credential ${this.credential.id}. Set a destination calendar in user settings.`);\n}","handlingStrategy":"validation","validationCode":"const destCal = event.destinationCalendar?.find((c) => c.credentialId === this.credential.id) ?? event.destinationCalendar?.[0];\nif (!destCal?.externalId) {\n  throw new Error(`No Feishu destination calendar set for credential ${this.credential.id}`);\n}","typeGuard":"const hasDestinationCalendar = (event: CalendarServiceEvent, credentialId: number): boolean =>\n  Array.isArray(event.destinationCalendar) &&\n  event.destinationCalendar.some((c) => typeof c.externalId === \"string\" && c.externalId.length > 0);","tryCatchPattern":"if (!calendarId) {\n  // surface user-actionable error\n  throw new Error(\"Select a Feishu calendar in user settings before booking.\");\n}","preventionTips":["Require a destinationCalendar before enabling Feishu as a booking calendar.","Validate destinationCalendar.externalId presence in the booking preflight.","Surface missing-calendar as a user-facing message, not a 500."],"tags":["feishu","larksuite","calendar","destination-calendar","validation"],"backgroundTag":null,"analyzedSha":"176037d0afbe572f870a3c702985e7cd83fe6c0c","analyzedAt":"2026-08-12T19:12:41.464Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}