SonarSource/sonarqube · error · IllegalArgumentException

Identity provider %s does not exist or is not enabled

Error message

Identity provider %s does not exist or is not enabled

What it means

IdentityProviderRepository.getEnabledByKey returns the identity provider (SAML, GitHub, etc.) registered under a key only if it is enabled, otherwise it throws IllegalArgumentException. The same message covers both 'no such provider' and 'provider exists but is disabled', deliberately not distinguishing them.

Source

Thrown at server/sonar-webserver-auth/src/main/java/org/sonar/server/authentication/IdentityProviderRepository.java:48

import org.sonar.api.server.authentication.IdentityProvider;

public class IdentityProviderRepository {
  private static final Predicate<IdentityProvider> IS_ENABLED_FILTER = IdentityProvider::isEnabled;
  private static final Function<IdentityProvider, String> TO_NAME = IdentityProvider::getName;

  protected final Map<String, IdentityProvider> providersByKey = new HashMap<>();

  public IdentityProviderRepository(@Nullable List<IdentityProvider> identityProviders) {
    Optional.ofNullable(identityProviders)
      .ifPresent(list -> list.forEach(i -> providersByKey.put(i.getKey(), i)));
  }

  public IdentityProvider getEnabledByKey(String key) {
    IdentityProvider identityProvider = providersByKey.get(key);
    if (identityProvider != null && IS_ENABLED_FILTER.test(identityProvider)) {
      return identityProvider;
    }
    throw new IllegalArgumentException(String.format("Identity provider %s does not exist or is not enabled", key));
  }

  public List<IdentityProvider> getAllEnabledAndSorted() {
    return providersByKey.values().stream()
      .filter(IS_ENABLED_FILTER)
      .sorted(Comparator.comparing(TO_NAME))
      .toList();
  }

}

View on GitHub (pinned to 184c821202)

Solutions

  1. Verify the provider key against the configured identity providers in Administration > Security
  2. Enable the identity provider (e.g. sonar.auth.github.enabled=true) and restart the server
  3. Update the login entry point/links to use an enabled provider key

Example fix

// before
IdentityProvider provider = identityProviderRepository.getEnabledByKey(request.getParameter("provider"));
// after
String key = request.getParameter("provider");
IdentityProvider provider = identityProviderRepository.getAllEnabledAndSorted().stream()
  .filter(p -> p.getKey().equals(key))
  .findFirst()
  .orElseThrow(() -> new BadRequestException("Identity provider is not available: " + key));
Defensive patterns

Strategy: validation

Validate before calling

boolean providerAvailable = identityProviderRepository.getAllEnabledAndSorted().stream()
  .anyMatch(p -> p.getKey().equals(providerKey));
if (!providerAvailable) { throw new BadRequestException("Identity provider unavailable: " + providerKey); }

Type guard

Optional<IdentityProvider> findEnabledProvider(IdentityProviderRepository repo, String key) {
  return repo.getAllEnabledAndSorted().stream().filter(p -> p.getKey().equals(key)).findFirst();
}

Try / catch

try {
  IdentityProvider provider = repo.getEnabledByKey(key);
  // start login flow
} catch (IllegalArgumentException e) {
  if (!e.getMessage().startsWith("Identity provider")) throw e;
  // render login page with only enabled providers instead of failing
}

Prevention

When it happens

Trigger: Calling getEnabledByKey(key) when the identity provider key is not configured in sonar.properties (sonar.auth.* settings) or the provider is registered but disabled — e.g. during SSO login redirects referencing a provider that was turned off.

Common situations: Users hitting login links for a provider disabled by an administrator after migration; typos in provider keys in external login buttons; authentication config changes (sonar.auth.github.enabled=false) while old links remain in bookmarks.

Understand the failure class

Background: 'Could not be found', 'does not exist', 'not found in database': the resource-not-found family when an ID, slug, key, or URI lookup comes back empty — this error's family across 20 libraries.

Related errors


AI-assisted analysis of SonarSource/sonarqube@184c821202 (2026-09-09). Data as JSON: /api/errors/20450b7aee289fa3. Report an issue: GitHub.