gitroomhq/postiz-app · error · Error

Auth provider not found

Error message

Auth provider ${provider} not found

What it means

The auth ProvidersManager scans registered provider modules and looks up the one whose metadata `provider` equals the requested provider string. If no module declares that provider identifier, it throws before resolving the implementation from the NestJS moduleRef.

Solutions

  1. Check which provider modules are imported in the Auth/Providers module and add the missing provider module
  2. Verify the provider string matches the metadata exactly (case-sensitive compare against the @Provider('x') decoration)
  3. Guard the endpoint/controller with an allowed-providers check so unknown values 400 early instead of 500
  4. If a provider was intentionally removed, remove it from the frontend provider list too

Example fix

// before
@Module({ imports: [AppleProviderModule, GoogleProviderModule] })
class AuthModule {}
// request with provider='discord' -> 'Auth provider discord not found'

// after
@Module({ imports: [AppleProviderModule, GoogleProviderModule, DiscordProviderModule] })
class AuthModule {}
Defensive patterns

Strategy: type-guard

Validate before calling

const registered = await providersApi.list(); // or a static list
if (!registered.includes(provider)) {
  throw new BadRequestException(`Unsupported provider: ${provider}`);
}
await authService.checkExists({ provider, code, state });

Type guard

const SUPPORTED_PROVIDERS = ['apple', 'google', 'facebook'] as const;
const isSupportedProvider = (p: string): p is typeof SUPPORTED_PROVIDERS[number] =>
  (SUPPORTED_PROVIDERS as readonly string[]).includes(p);

Try / catch

try {
  await authService.checkExists({ provider, code, state });
} catch (e) {
  if (e instanceof Error && e.message.includes('not found')) {
    return res.status(400).json({ error: `Unsupported provider ${provider}` });
  }
  throw e;
}

Prevention

When it happens

Trigger: Calling checkExists/OAuth flow with a provider value that no decorated provider module registers (e.g. 'facebook' when only a subset of provider modules are imported into the AuthModule), or a typo/casing mismatch in the provider param.

Common situations: New provider added to the frontend dropdown but its module isn't registered in the backend auth module; provider string casing mismatch ('Apple' vs 'apple'); conditional compilation/exclusion of provider modules per deployment; stale enum vs registered metadata divergence after a refactor.

Related errors


AI-assisted analysis of gitroomhq/postiz-app@0f1647f749 (2026-08-27). Data as JSON: /api/errors/79aa1d0088d2ad26. Report an issue: GitHub.

Appendix: source

Thrown at apps/backend/src/services/auth/providers/providers.manager.ts:18

import { Injectable } from '@nestjs/common';
import { ModuleRef } from '@nestjs/core';
import { AuthProviderAbstract } from '@gitroom/backend/services/auth/providers.interface';

@Injectable()
export class AuthProviderManager {
  constructor(private _moduleRef: ModuleRef) {}

  getProvider(provider: string): AuthProviderAbstract {
    const metadata =
      Reflect.getMetadata('auth-provider', AuthProviderAbstract) || [];

    const found = metadata.find(
      (m: any) => m.provider === provider
    );

    if (!found) {
      throw new Error(`Auth provider ${provider} not found`);
    }

    return this._moduleRef.get(found.target, { strict: false });
  }
}

View on GitHub (pinned to 0f1647f749)