calcom/cal.diy · error · HttpException

${err.message}

Error message

${err.message}

What it means

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.

Source

Thrown at apps/api/v2/src/modules/auth/oauth2/controllers/atoms-oauth2.controller.ts:50

  @ApiOperation({ summary: "Get a provider" })
  async getClient(@Param("clientId") clientId: string) {
    if (!clientId) {
      throw new NotFoundException();
    }
    try {
      const client = await this.oAuthService.getClient(clientId);

      return {
        status: SUCCESS_STATUS,
        data: {
          clientId: client.clientId,
          organizationId: null,
        },
      };
    } catch (err: unknown) {
      if (err instanceof ErrorWithCode) {
        const statusCode = getHttpStatusCode(err);
        throw new HttpException(err.message, statusCode);
      }
      this.logger.error(err);
      throw new InternalServerErrorException("Could not get oAuthClient");
    }
  }
}

View on GitHub (pinned to 176037d0af)

Solutions

  1. Confirm the clientId exists and is active in the platform dashboard.
  2. Ensure the caller's credentials grant access to that OAuth client (same org scope).
  3. Inspect the ErrorWithCode.code and message from the response body to identify the specific domain failure and address it.
  4. If the status code looks wrong, verify getHttpStatusCode maps the ErrorWithCode.code to the intended HTTP status.
Defensive patterns

Strategy: try-catch

Validate before calling

// Pre-flight: confirm the client exists and the caller can see it
const exists = await oAuthClientRepository.exists(clientId);
if (!exists) { /* avoid the typed 404 */ }

Type guard

function isErrorWithCode(e: unknown): e is { code: string; message: string } {
  return e instanceof ErrorWithCode;
}

Try / catch

try {
  const { data } = await api.get(`/v2/atoms/oauth/clients/${clientId}`);
} catch (e) {
  // e.response.data.message === err.message; status === getHttpStatusCode(err.code)
  if (e.response?.status === 404) { /* client id is wrong/deleted */ }
  throw e;
}

Prevention

When it happens

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

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

Related errors


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