{"record":{"id":"542925f30e534935","repo":"calcom/cal.diy","slug":"google-meet-requires-a-valid-google-calendar-conne","errorCode":null,"errorMessage":"Google Meet requires a valid Google Calendar connection. Please reconnect Google Calendar.","messagePattern":"Google Meet requires a valid Google Calendar connection\\. Please reconnect Google Calendar\\.","errorType":"http","errorClass":"BadRequestException","httpStatus":400,"severity":"error","filePath":"apps/api/v2/src/modules/conferencing/services/google-meet.service.ts","lineNumber":56,"sourceCode":"\n    return this.credentialsRepository.upsertTeamAppCredential(GOOGLE_MEET_TYPE, {}, teamId);\n  }\n\n  /**\n   * Validate that Google Calendar is connected and valid for either a user or a team.\n   */\n  private async validateGoogleCalendarConnection(id: number, entity: \"user\" | \"team\") {\n    const googleCalendar =\n      entity === \"user\"\n        ? await this.credentialsRepository.findCredentialByTypeAndUserId(GOOGLE_CALENDAR_TYPE, id)\n        : await this.credentialsRepository.findCredentialByTypeAndTeamId(GOOGLE_CALENDAR_TYPE, id);\n\n    if (!googleCalendar) {\n      throw new BadRequestException(\"Google Meet requires a Google Calendar connection.\");\n    }\n\n    if (googleCalendar.invalid) {\n      throw new BadRequestException(\n        \"Google Meet requires a valid Google Calendar connection. Please reconnect Google Calendar.\"\n      );\n    }\n  }\n}\n","sourceCodeStart":38,"sourceCodeEnd":62,"githubUrl":"https://github.com/calcom/cal.diy/blob/176037d0afbe572f870a3c702985e7cd83fe6c0c/apps/api/v2/src/modules/conferencing/services/google-meet.service.ts#L38-L62","documentation":"Thrown in validateGoogleCalendarConnection when a Google Calendar credential exists but its `invalid` flag is truthy. This means the credential record is present but marked as no longer usable (token refresh failed, revoked, or manually flagged). The service refuses to attach Google Meet to a broken Calendar credential and tells the user to reconnect, raising BadRequestException (HTTP 400).","triggerScenarios":"The Google Calendar credential's refresh token expired or was revoked by Google, the system set invalid=true during a sync failure, and now the user attempts to connect Google Meet. The `if (googleCalendar.invalid)` branch fires.","commonSituations":"Long-inactive accounts whose refresh token lapsed; password change on the Google account invalidating tokens; admin revoked app permissions in Google security settings; the calendar sync job flagged invalid after repeated 401s.","solutions":["Reconnect Google Calendar: delete the invalid credential and run the Google Calendar OAuth flow again to get fresh tokens.","After reconnect, confirm the new credential has invalid=false before retrying the Google Meet connect.","Investigate why the credential was invalidated (audit logs) if this recurs across many users."],"exampleFix":"// before - calendar credential exists but invalid=true\nawait googleMeetService.connectGoogleMeetToUser(userId);\n\n// after - force re-auth of calendar first\nawait googleCalendarService.disconnect(userId);\nawait googleCalendarService.connect(userId);\nawait googleMeetService.connectGoogleMeetToUser(userId);","handlingStrategy":"validation","validationCode":"const gcal = await credentialsRepository.findCredentialByTypeAndUserId(GOOGLE_CALENDAR_TYPE, userId);\nif (gcal?.invalid) {\n  // force re-auth flow for Google Calendar before proceeding\n  await googleCalendarService.reconnect(userId);\n}\nawait googleMeetService.connectGoogleMeetToUser(userId);","typeGuard":"const isInvalidCredential = (c: { invalid?: boolean } | null): c is { invalid: true } =>\n  !!c && c.invalid === true;","tryCatchPattern":"try {\n  await googleMeetService.connectGoogleMeetToUser(userId);\n} catch (e) {\n  if (e instanceof BadRequestException && /valid Google Calendar/.test(e.message)) {\n    await googleCalendarService.disconnect(userId);\n    await googleCalendarService.connect(userId);\n    return googleMeetService.connectGoogleMeetToUser(userId);\n  }\n  throw e;\n}","preventionTips":["Monitor the invalid flag during calendar sync and proactively prompt reconnection.","Show a 'reconnect Google Calendar' banner when invalid is true.","Audit refresh-token failures to catch invalidation early."],"tags":["conferencing","google-meet","google-calendar","invalid-credential","oauth","reconnect"],"backgroundTag":null,"analyzedSha":"176037d0afbe572f870a3c702985e7cd83fe6c0c","analyzedAt":"2026-08-12T19:12:41.464Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}