{"record":{"id":"f723a87d49b83ad2","repo":"calcom/cal.diy","slug":"not-found","errorCode":null,"errorMessage":"Not Found","messagePattern":"Not Found","errorType":"http","errorClass":"NotFoundException","httpStatus":404,"severity":"error","filePath":"apps/api/v2/src/platform/calendars/services/gcal.service.ts","lineNumber":91,"sourceCode":"      isDryRun,\n    };\n\n    const authUrl = oAuth2Client.generateAuthUrl({\n      access_type: \"offline\",\n      scope: CALENDAR_SCOPES,\n      prompt: \"consent\",\n      state: JSON.stringify(state),\n    });\n\n    return authUrl;\n  }\n\n  async getOAuthClient(redirectUri: string) {\n    this.logger.log(\"Getting Google Calendar OAuth Client\");\n    const app = await this.appsRepository.getAppBySlug(\"google-calendar\");\n\n    if (!app) {\n      throw new NotFoundException();\n    }\n\n    const { client_id, client_secret } = this.gcalResponseSchema.parse(app.keys);\n\n    const oAuth2Client = new OAuth2Client(client_id, client_secret, redirectUri);\n    return oAuth2Client;\n  }\n\n  async checkIfCalendarConnected(userId: number): Promise<{ status: typeof SUCCESS_STATUS }> {\n    const gcalCredentials = await this.credentialRepository.findCredentialByTypeAndUserId(\n      \"google_calendar\",\n      userId\n    );\n\n    if (!gcalCredentials) {\n      throw new BadRequestException(\"Credentials for google_calendar not found.\");\n    }\n","sourceCodeStart":73,"sourceCodeEnd":109,"githubUrl":"https://github.com/calcom/cal.diy/blob/176037d0afbe572f870a3c702985e7cd83fe6c0c/apps/api/v2/src/platform/calendars/services/gcal.service.ts#L73-L109","documentation":"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.","triggerScenarios":"Calling google_calendar connect/save before the app is seeded; app uninstalled or disabled; slug mismatch in the DB.","commonSituations":"Fresh environment without app-store seed data; app disabled in admin; a migration that dropped the google-calendar row.","solutions":["Seed/install the google-calendar app so the App row exists with slug 'google-calendar'.","Confirm: SELECT slug, keys FROM apps WHERE slug='google-calendar' returns a row with populated keys.","Improve the error message to name the missing app."],"exampleFix":"// before: bare 'Not Found' 404\nif (!app) { throw new NotFoundException(); }\n\n// after: name the missing app\nif (!app) { throw new NotFoundException(`Google Calendar app is not installed or configured.`); }","handlingStrategy":"validation","validationCode":"// Startup check: ensure google-calendar app is installed\nconst app = await appsRepository.getAppBySlug('google-calendar');\nif (!app) throw new ConfigError('google-calendar app not seeded — OAuth unavailable');","typeGuard":"function isGoogleAppInstalled(app) {\n  return !!app && !!app.keys && typeof app.keys.client_id === 'string';\n}","tryCatchPattern":"try {\n  await api.post('/v2/calendars/google_calendar/connect', {});\n} catch (e) {\n  if (e.response?.status === 404) {\n    throw new ConfigError('Google Calendar app is not installed/configured on the server.');\n  }\n  throw e;\n}","preventionTips":["Seed the google-calendar App row (slug + OAuth keys) in every environment.","Add a startup health check that the google-calendar app exists with populated keys.","Replace the bare NotFoundException() with a descriptive message naming the missing app."],"tags":["google-calendar","app-keys","configuration","seed","diagnosability","http-404"],"backgroundTag":null,"analyzedSha":"176037d0afbe572f870a3c702985e7cd83fe6c0c","analyzedAt":"2026-08-12T19:12:41.464Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}