calcom/cal.diy · error · InternalServerErrorException

Could not get oAuthClient

Error message

Could not get oAuthClient

What it means

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.

Source

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

      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. Inspect server logs (this.logger.error output) for the original error stack — the 500 response intentionally hides it.
  2. If the cause is a DB/connectivity issue, restore database connectivity and retry.
  3. As a platform maintainer: ensure getClient wraps all failure modes in ErrorWithCode so callers receive a meaningful status instead of a 500.
  4. Check that Prisma/DATABASE_URL is correctly configured for this environment.
Defensive patterns

Strategy: retry

Type guard

function isUnexpectedError(e: unknown): boolean {
  return !(e instanceof ErrorWithCode);
}

Try / catch

try {
  await api.get(`/v2/atoms/oauth/clients/${clientId}`);
} catch (e) {
  if (e.response?.status === 500) {
    // inspect server logs; retry once after a short backoff if transient
    await backoff();
    return api.get(`/v2/atoms/oauth/clients/${clientId}`);
  }
  throw e;
}

Prevention

When it happens

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

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

Related errors


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