calcom/cal.diy · error · NotFoundException

Not Found

Error message

Not Found

What it means

Thrown by GoogleCalendarService.getOAuthClient (gcal.service.ts:91) as a bare NotFoundException() (HTTP 404, default 'Not Found' message) when appsRepository.getAppBySlug('google-calendar') returns null — the Google Calendar App row is not in the database. Blocks the entire Google OAuth redirect/save flow. Same diagnosability defect as 371/372/373.

Source

Thrown at apps/api/v2/src/platform/calendars/services/gcal.service.ts:91

      isDryRun,
    };

    const authUrl = oAuth2Client.generateAuthUrl({
      access_type: "offline",
      scope: CALENDAR_SCOPES,
      prompt: "consent",
      state: JSON.stringify(state),
    });

    return authUrl;
  }

  async getOAuthClient(redirectUri: string) {
    this.logger.log("Getting Google Calendar OAuth Client");
    const app = await this.appsRepository.getAppBySlug("google-calendar");

    if (!app) {
      throw new NotFoundException();
    }

    const { client_id, client_secret } = this.gcalResponseSchema.parse(app.keys);

    const oAuth2Client = new OAuth2Client(client_id, client_secret, redirectUri);
    return oAuth2Client;
  }

  async checkIfCalendarConnected(userId: number): Promise<{ status: typeof SUCCESS_STATUS }> {
    const gcalCredentials = await this.credentialRepository.findCredentialByTypeAndUserId(
      "google_calendar",
      userId
    );

    if (!gcalCredentials) {
      throw new BadRequestException("Credentials for google_calendar not found.");
    }

View on GitHub (pinned to 176037d0af)

Solutions

  1. Seed/install the google-calendar app so the App row exists with slug 'google-calendar'.
  2. Confirm: SELECT slug, keys FROM apps WHERE slug='google-calendar' returns a row with populated keys.
  3. Improve the error message to name the missing app.

Example fix

// before: bare 'Not Found' 404
if (!app) { throw new NotFoundException(); }

// after: name the missing app
if (!app) { throw new NotFoundException(`Google Calendar app is not installed or configured.`); }
Defensive patterns

Strategy: validation

Validate before calling

// Startup check: ensure google-calendar app is installed
const app = await appsRepository.getAppBySlug('google-calendar');
if (!app) throw new ConfigError('google-calendar app not seeded — OAuth unavailable');

Type guard

function isGoogleAppInstalled(app) {
  return !!app && !!app.keys && typeof app.keys.client_id === 'string';
}

Try / catch

try {
  await api.post('/v2/calendars/google_calendar/connect', {});
} catch (e) {
  if (e.response?.status === 404) {
    throw new ConfigError('Google Calendar app is not installed/configured on the server.');
  }
  throw e;
}

Prevention

When it happens

Trigger: Calling google_calendar connect/save before the app is seeded; app uninstalled or disabled; slug mismatch in the DB.

Common situations: Fresh environment without app-store seed data; app disabled in admin; a migration that dropped the google-calendar row.

Related errors


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