{"record":{"id":"8ef9ccd6f7ba09a6","repo":"calcom/cal.diy","slug":"could-not-get-oauthclient","errorCode":null,"errorMessage":"Could not get oAuthClient","messagePattern":"Could not get oAuthClient","errorType":"http","errorClass":"InternalServerErrorException","httpStatus":500,"severity":"error","filePath":"apps/api/v2/src/modules/auth/oauth2/controllers/atoms-oauth2.controller.ts","lineNumber":53,"sourceCode":"      throw new NotFoundException();\n    }\n    try {\n      const client = await this.oAuthService.getClient(clientId);\n\n      return {\n        status: SUCCESS_STATUS,\n        data: {\n          clientId: client.clientId,\n          organizationId: null,\n        },\n      };\n    } catch (err: unknown) {\n      if (err instanceof ErrorWithCode) {\n        const statusCode = getHttpStatusCode(err);\n        throw new HttpException(err.message, statusCode);\n      }\n      this.logger.error(err);\n      throw new InternalServerErrorException(\"Could not get oAuthClient\");\n    }\n  }\n}\n","sourceCodeStart":35,"sourceCodeEnd":57,"githubUrl":"https://github.com/calcom/cal.diy/blob/176037d0afbe572f870a3c702985e7cd83fe6c0c/apps/api/v2/src/modules/auth/oauth2/controllers/atoms-oauth2.controller.ts#L35-L57","documentation":"InternalServerErrorException('Could not get oAuthClient') from AtomsOAuth2Controller.getClient — the fallback when oAuthService.getClient(clientId) rejects with something that is NOT an ErrorWithCode (a plain Error, a TypeError, a Prisma error, etc.). The original error is logged via this.logger.error(err) before the generic 500 is returned, so the real cause is in server logs, not the response.","triggerScenarios":"GET to the atoms OAuth client info endpoint when getClient throws a non-ErrorWithCode exception — e.g. a database connection failure, a null-dereference, a Prisma internal error, or any unhandled runtime error inside the service.","commonSituations":"Database is down or unreachable; Prisma query timed out; null reference inside getClient; a dependency threw a plain Error instead of an ErrorWithCode; transient network issue to the DB.","solutions":["Inspect server logs (this.logger.error output) for the original error stack — the 500 response intentionally hides it.","If the cause is a DB/connectivity issue, restore database connectivity and retry.","As a platform maintainer: ensure getClient wraps all failure modes in ErrorWithCode so callers receive a meaningful status instead of a 500.","Check that Prisma/DATABASE_URL is correctly configured for this environment."],"exampleFix":null,"handlingStrategy":"retry","validationCode":null,"typeGuard":"function isUnexpectedError(e: unknown): boolean {\n  return !(e instanceof ErrorWithCode);\n}","tryCatchPattern":"try {\n  await api.get(`/v2/atoms/oauth/clients/${clientId}`);\n} catch (e) {\n  if (e.response?.status === 500) {\n    // inspect server logs; retry once after a short backoff if transient\n    await backoff();\n    return api.get(`/v2/atoms/oauth/clients/${clientId}`);\n  }\n  throw e;\n}","preventionTips":["Monitor server logs for the original this.logger.error output — the response hides it.","Ensure DB connectivity (DATABASE_URL) and that Prisma is healthy.","As maintainer: wrap all getClient failure modes in ErrorWithCode to remove opaque 500s."],"tags":["oauth","controller","internal-error","database","atoms-api"],"backgroundTag":null,"analyzedSha":"176037d0afbe572f870a3c702985e7cd83fe6c0c","analyzedAt":"2026-08-12T19:12:41.464Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}