{"record":{"id":"6b6f63c0c149ac8c","repo":"calcom/cal.diy","slug":"could-not-find-calendar-credentials-for-ctx-inte","errorCode":null,"errorMessage":"Could not find calendar credentials for ${ctx.integrationSlug}. Please reconnect your calendar.","messagePattern":"Could not find calendar credentials for (.+?)\\. Please reconnect your calendar\\.","errorType":"http","errorClass":"BadRequestException","httpStatus":400,"severity":"error","filePath":"apps/api/v2/src/platform/bookings/2024-08-13/services/booking-location-integration.service.ts","lineNumber":265,"sourceCode":"    requiredCalendarType: string\n  ): Promise<BookingLocationResponse> {\n    const calendarReference = ctx.booking.references.find(\n      (ref) => ref.type.includes(requiredCalendarType) && !ref.deleted\n    );\n\n    if (!calendarReference) {\n      throw new BadRequestException(\n        `No ${requiredCalendarType.replace(\"_\", \" \")} event found for this booking. ${ctx.integrationSlug} requires a ${requiredCalendarType.replace(\"_\", \" \")} event to generate the meeting link.`\n      );\n    }\n\n    const calendarCredential = await this.credentialService.getCredentialForReference(\n      calendarReference,\n      ctx.booking.user?.credentials || []\n    );\n\n    if (!calendarCredential) {\n      throw new BadRequestException(\n        `Could not find calendar credentials for ${ctx.integrationSlug}. Please reconnect your calendar.`\n      );\n    }\n\n    const evt = await this.calendarSyncService.buildCalEventFromBookingData(\n      ctx.booking,\n      ctx.internalLocation,\n      null\n    );\n\n    if (ctx.integrationSlug === \"google-meet\") {\n      evt.conferenceData = {\n        createRequest: {\n          requestId: `${ctx.booking.uid}-meet`,\n        },\n      };\n    }\n","sourceCodeStart":247,"sourceCodeEnd":283,"githubUrl":"https://github.com/calcom/cal.diy/blob/176037d0afbe572f870a3c702985e7cd83fe6c0c/apps/api/v2/src/platform/bookings/2024-08-13/services/booking-location-integration.service.ts#L247-L283","documentation":"Thrown by handleCalendarBasedIntegration when a calendar reference exists but credentialService.getCredentialForReference returns no matching credential among the user's credentials. The reference points at a credential ID that no longer exists, so the calendar event cannot be updated to attach the meeting link.","triggerScenarios":"PATCH booking location to a calendar-based integration (google-meet, office365-video calendar path) where the booking has a non-deleted calendar reference, but the credential row it references has been deleted or does not belong to the booking host.","commonSituations":"User disconnected the calendar app after the booking was created (credential deleted but reference retained); credential revoked by the provider; user reconnected under a different account so the old credentialId is orphaned; cross-user credential mismatch.","solutions":["Have the organizer reconnect the calendar integration in Settings to create a fresh credential.","Re-sync/re-create the booking's calendar event so a new reference tied to the new credential is generated.","If the credential belongs to a different user, ensure the booking host is the one who owns the connected calendar."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"// Before PATCHing, confirm the calendar reference has a resolvable credential.\nconst refs = await api.get(`/v2/bookings/${uid}/references`);\nconst calRef = refs.find((r) => r.type.includes('google_calendar') && !r.deleted);\nif (calRef && !calRef.credentialId) throw new Error('Calendar reference has no credential; reconnect the calendar');","typeGuard":"function referenceHasCredential(ref: { credentialId?: number | null } | undefined): boolean {\n  return !!ref && ref.credentialId != null && ref.credentialId > 0;\n}","tryCatchPattern":"try {\n  await api.patch(`/v2/bookings/${uid}/location`, { location: { type: 'integration', integration: 'google-meet' } });\n} catch (err) {\n  if (err.status === 400 && /calendar credentials/.test(err.message)) {\n    // host must reconnect the calendar and re-sync\n  }\n  throw err;\n}","preventionTips":["Reconnect the calendar app after disconnecting to refresh the credential.","Re-sync bookings so references point at current credentials.","Ensure the booking host owns the connected calendar credential."],"tags":["credentials","calendar","oauth","references"],"backgroundTag":null,"analyzedSha":"176037d0afbe572f870a3c702985e7cd83fe6c0c","analyzedAt":"2026-08-12T19:12:41.464Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}