calcom/cal.diy · error · BadRequestException

Google Meet requires a valid Google Calendar connection. Ple

Error message

Google Meet requires a valid Google Calendar connection. Please reconnect Google Calendar.

What it means

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).

Source

Thrown at apps/api/v2/src/modules/conferencing/services/google-meet.service.ts:56

    return this.credentialsRepository.upsertTeamAppCredential(GOOGLE_MEET_TYPE, {}, teamId);
  }

  /**
   * Validate that Google Calendar is connected and valid for either a user or a team.
   */
  private async validateGoogleCalendarConnection(id: number, entity: "user" | "team") {
    const googleCalendar =
      entity === "user"
        ? await this.credentialsRepository.findCredentialByTypeAndUserId(GOOGLE_CALENDAR_TYPE, id)
        : await this.credentialsRepository.findCredentialByTypeAndTeamId(GOOGLE_CALENDAR_TYPE, id);

    if (!googleCalendar) {
      throw new BadRequestException("Google Meet requires a Google Calendar connection.");
    }

    if (googleCalendar.invalid) {
      throw new BadRequestException(
        "Google Meet requires a valid Google Calendar connection. Please reconnect Google Calendar."
      );
    }
  }
}

View on GitHub (pinned to 176037d0af)

Solutions

  1. Reconnect Google Calendar: delete the invalid credential and run the Google Calendar OAuth flow again to get fresh tokens.
  2. After reconnect, confirm the new credential has invalid=false before retrying the Google Meet connect.
  3. Investigate why the credential was invalidated (audit logs) if this recurs across many users.

Example fix

// before - calendar credential exists but invalid=true
await googleMeetService.connectGoogleMeetToUser(userId);

// after - force re-auth of calendar first
await googleCalendarService.disconnect(userId);
await googleCalendarService.connect(userId);
await googleMeetService.connectGoogleMeetToUser(userId);
Defensive patterns

Strategy: validation

Validate before calling

const gcal = await credentialsRepository.findCredentialByTypeAndUserId(GOOGLE_CALENDAR_TYPE, userId);
if (gcal?.invalid) {
  // force re-auth flow for Google Calendar before proceeding
  await googleCalendarService.reconnect(userId);
}
await googleMeetService.connectGoogleMeetToUser(userId);

Type guard

const isInvalidCredential = (c: { invalid?: boolean } | null): c is { invalid: true } =>
  !!c && c.invalid === true;

Try / catch

try {
  await googleMeetService.connectGoogleMeetToUser(userId);
} catch (e) {
  if (e instanceof BadRequestException && /valid Google Calendar/.test(e.message)) {
    await googleCalendarService.disconnect(userId);
    await googleCalendarService.connect(userId);
    return googleMeetService.connectGoogleMeetToUser(userId);
  }
  throw e;
}

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Related errors


AI-assisted analysis of calcom/cal.diy@176037d0af (2026-08-12). Data as JSON: /api/errors/542925f30e534935. Report an issue: GitHub.