calcom/cal.diy · error · NotFoundException

OAuth Client with ID ${oAuthClientId} not found

Error message

OAuth Client with ID ${oAuthClientId} not found

What it means

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.

Source

Thrown at apps/api/v2/src/modules/oauth-clients/controllers/oauth-client-users/oauth-client-users.controller.ts:94

      status: SUCCESS_STATUS,
      data: managedUsers.map((user) => this.oAuthClientUsersOutputService.getResponseUser(user)),
    };
  }

  @Post("/")
  @ApiOperation({
    summary: "Create a managed user",
    description: `<Warning>These endpoints are deprecated and will be removed in the future.</Warning>`,
  })
  @MembershipRoles([MembershipRole.ADMIN, MembershipRole.OWNER])
  async createUser(
    @Param("clientId") oAuthClientId: string,
    @Body() body: CreateManagedUserInput
  ): Promise<CreateManagedUserOutput> {
    this.logger.log(`Creating user for OAuth Client ${oAuthClientId}`);
    const client = await this.oauthRepository.getOAuthClient(oAuthClientId);
    if (!client) {
      throw new NotFoundException(`OAuth Client with ID ${oAuthClientId} not found`);
    }

    const { user, tokens } = await this.oAuthClientUsersService.createOAuthClientUser(client, body);

    return {
      status: SUCCESS_STATUS,
      data: {
        user: this.oAuthClientUsersOutputService.getResponseUser(user),
        accessToken: tokens.accessToken,
        accessTokenExpiresAt: tokens.accessTokenExpiresAt.valueOf(),
        refreshToken: tokens.refreshToken,
        refreshTokenExpiresAt: tokens.refreshTokenExpiresAt.valueOf(),
      },
    };
  }

  @Get("/:userId")
  @HttpCode(HttpStatus.OK)

View on GitHub (pinned to 176037d0af)

Solutions

  1. Verify the clientId via a GET /oauth-clients listing and copy the exact id.
  2. Confirm you are targeting the correct environment (the client must exist in the same database).
  3. Trim and URL-safe-encode the id when building the request path.
Defensive patterns

Strategy: validation

Validate before calling

const client = await oauthRepository.getOAuthClient(oAuthClientId);
if (!client) {
  throw new NotFoundException(`OAuth Client with ID ${oAuthClientId} not found`);
}

Type guard

const isExistingClientId = async (id: string): Promise<boolean> => !!(await oauthRepository.getOAuthClient(id));

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Related errors


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