{"record":{"id":"0d048d7cd9bdc743","repo":"calcom/cal.diy","slug":"err-message","errorCode":null,"errorMessage":"${err.message}","messagePattern":"\\$\\{err\\.message\\}","errorType":"http","errorClass":"HttpException","httpStatus":null,"severity":"error","filePath":"apps/api/v2/src/modules/auth/oauth2/controllers/atoms-oauth2.controller.ts","lineNumber":50,"sourceCode":"  @ApiOperation({ summary: \"Get a provider\" })\n  async getClient(@Param(\"clientId\") clientId: string) {\n    if (!clientId) {\n      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":32,"sourceCodeEnd":57,"githubUrl":"https://github.com/calcom/cal.diy/blob/176037d0afbe572f870a3c702985e7cd83fe6c0c/apps/api/v2/src/modules/auth/oauth2/controllers/atoms-oauth2.controller.ts#L32-L57","documentation":"A re-thrown HttpException from AtomsOAuth2Controller.getClient: when oAuthService.getClient(clientId) rejects with an ErrorWithCode, the controller maps it to an HttpException using getHttpStatusCode(err) for the status and err.message for the body. This preserves the typed domain error (e.g. not-found, unauthorized) as a proper HTTP response rather than a generic 500.","triggerScenarios":"GET to the atoms OAuth client info endpoint with a clientId for which getClient throws an ErrorWithCode — typically a not-found client, an unauthorized access scenario, or another domain-coded failure inside oAuthService.getClient.","commonSituations":"clientId does not exist; caller lacks permission to view the client; client is archived/deleted; service throws a typed ErrorWithCode for any business rule (e.g. wrong org scope).","solutions":["Confirm the clientId exists and is active in the platform dashboard.","Ensure the caller's credentials grant access to that OAuth client (same org scope).","Inspect the ErrorWithCode.code and message from the response body to identify the specific domain failure and address it.","If the status code looks wrong, verify getHttpStatusCode maps the ErrorWithCode.code to the intended HTTP status."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"// Pre-flight: confirm the client exists and the caller can see it\nconst exists = await oAuthClientRepository.exists(clientId);\nif (!exists) { /* avoid the typed 404 */ }","typeGuard":"function isErrorWithCode(e: unknown): e is { code: string; message: string } {\n  return e instanceof ErrorWithCode;\n}","tryCatchPattern":"try {\n  const { data } = await api.get(`/v2/atoms/oauth/clients/${clientId}`);\n} catch (e) {\n  // e.response.data.message === err.message; status === getHttpStatusCode(err.code)\n  if (e.response?.status === 404) { /* client id is wrong/deleted */ }\n  throw e;\n}","preventionTips":["Use the dashboard to confirm the clientId before querying.","Handle ErrorWithCode status codes per the documented code→HTTP mapping.","Log err.code (not the raw payload) for triage."],"tags":["oauth","controller","errorwithcode","atoms-api","http-mapping"],"backgroundTag":null,"analyzedSha":"176037d0afbe572f870a3c702985e7cd83fe6c0c","analyzedAt":"2026-08-12T19:12:41.464Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}