{"record":{"id":"e444573689079e0a","repo":"calcom/cal.diy","slug":"oauth-client-with-id-oauthclientid-not-found","errorCode":null,"errorMessage":"OAuth Client with ID ${oAuthClientId} not found","messagePattern":"OAuth Client with ID (.+?) not found","errorType":"exception","errorClass":"NotFoundException","httpStatus":404,"severity":"error","filePath":"apps/api/v2/src/modules/oauth-clients/controllers/oauth-client-users/oauth-client-users.controller.ts","lineNumber":94,"sourceCode":"      status: SUCCESS_STATUS,\n      data: managedUsers.map((user) => this.oAuthClientUsersOutputService.getResponseUser(user)),\n    };\n  }\n\n  @Post(\"/\")\n  @ApiOperation({\n    summary: \"Create a managed user\",\n    description: `<Warning>These endpoints are deprecated and will be removed in the future.</Warning>`,\n  })\n  @MembershipRoles([MembershipRole.ADMIN, MembershipRole.OWNER])\n  async createUser(\n    @Param(\"clientId\") oAuthClientId: string,\n    @Body() body: CreateManagedUserInput\n  ): Promise<CreateManagedUserOutput> {\n    this.logger.log(`Creating user for OAuth Client ${oAuthClientId}`);\n    const client = await this.oauthRepository.getOAuthClient(oAuthClientId);\n    if (!client) {\n      throw new NotFoundException(`OAuth Client with ID ${oAuthClientId} not found`);\n    }\n\n    const { user, tokens } = await this.oAuthClientUsersService.createOAuthClientUser(client, body);\n\n    return {\n      status: SUCCESS_STATUS,\n      data: {\n        user: this.oAuthClientUsersOutputService.getResponseUser(user),\n        accessToken: tokens.accessToken,\n        accessTokenExpiresAt: tokens.accessTokenExpiresAt.valueOf(),\n        refreshToken: tokens.refreshToken,\n        refreshTokenExpiresAt: tokens.refreshTokenExpiresAt.valueOf(),\n      },\n    };\n  }\n\n  @Get(\"/:userId\")\n  @HttpCode(HttpStatus.OK)","sourceCodeStart":76,"sourceCodeEnd":112,"githubUrl":"https://github.com/calcom/cal.diy/blob/176037d0afbe572f870a3c702985e7cd83fe6c0c/apps/api/v2/src/modules/oauth-clients/controllers/oauth-client-users/oauth-client-users.controller.ts#L76-L112","documentation":"Thrown by OAuthClientUsersController.createUser when oauthRepository.getOAuthClient(oAuthClientId) returns falsy. The controller receives clientId from @Param('clientId'), logs the creation attempt, looks up the OAuth client, and raises NotFoundException (HTTP 404) if none matches. This happens before any managed-user creation logic runs.","triggerScenarios":"POST to /oauth-clients/:clientId/users (create managed user) with a clientId that does not exist in the oauthClients table — typo, wrong environment, or a deleted client.","commonSituations":"Client id copied partially or with extra whitespace; test hitting dev with a prod client id (or vice versa); the OAuth client was deleted but a downstream integration still references it; URL-encoding mangled the id.","solutions":["Verify the clientId via a GET /oauth-clients listing and copy the exact id.","Confirm you are targeting the correct environment (the client must exist in the same database).","Trim and URL-safe-encode the id when building the request path."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"const client = await oauthRepository.getOAuthClient(oAuthClientId);\nif (!client) {\n  throw new NotFoundException(`OAuth Client with ID ${oAuthClientId} not found`);\n}","typeGuard":"const isExistingClientId = async (id: string): Promise<boolean> => !!(await oauthRepository.getOAuthClient(id));","tryCatchPattern":null,"preventionTips":["Fetch the OAuth client list and copy the exact id.","Target the environment where the client actually exists.","Trim/encode the id when constructing the URL."],"tags":["oauth-clients","managed-users","not-found","controller","nestjs"],"backgroundTag":null,"analyzedSha":"176037d0afbe572f870a3c702985e7cd83fe6c0c","analyzedAt":"2026-08-12T19:12:41.464Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}