Kareadita/Kavita · error · KavitaException
errors.oidc.creating-user
Error message
errors.oidc.creating-user
What it means
Thrown by CreateNewAccount's catch-all: NewUserFromOpenIdConnect threw an exception that was not itself a KavitaException (those are rethrown verbatim). Any unexpected failure during account creation — DB error, Identity manager fault, missing dependency — is normalized to this generic message. The original exception is logged via LogError before the throw.
Source
Thrown at Kavita.Services/OidcService.cs:229
if (settings.SyncUserSettings && !isAllowedToBeCreated)
{
logger.LogDebug("Login role was not found under claim {Claim} with prefix {Prefix}", settings.RolesClaim, settings.RolesPrefix);
throw new KavitaException("errors.oidc.role-not-assigned");
}
try
{
return await NewUserFromOpenIdConnect(request, settings, principal, oidcId);
}
catch (KavitaException)
{
throw;
}
catch (Exception e)
{
logger.LogError(e, "An error occured creating a new user");
throw new KavitaException("errors.oidc.creating-user");
}
}
/// <summary>
/// Find the best available name from claims
/// </summary>
/// <param name="claimsPrincipal"></param>
/// <param name="orEqualTo">Also return if the claim is equal to this value</param>
/// <returns></returns>
public async Task<string?> FindBestAvailableName(ClaimsPrincipal claimsPrincipal, string? orEqualTo = null)
{
var nameCandidates = new[]
{
claimsPrincipal.FindFirstValue(JwtRegisteredClaimNames.PreferredUsername),
claimsPrincipal.FindFirstValue(ClaimTypes.Name),
claimsPrincipal.FindFirstValue(ClaimTypes.GivenName),
claimsPrincipal.FindFirstValue(ClaimTypes.Surname)View on GitHub (pinned to 9c3e540000)
Solutions
- Read the preceding LogError entry — it logs the real exception (e) with 'An error occured creating a new user'.
- Resolve the underlying cause (DB connectivity, migration, constraint) identified in that log.
- If it's a race on duplicate username/email, ensure the principal's claims are unique before retry.
- Confirm GetDefaultTheme returns a non-null theme (seed themes / migrations applied).
Defensive patterns
Strategy: try-catch
Try / catch
try { var user = await oidcService.LoginOrCreate(Request, principal, ct); }
catch (KavitaException ex) when (ex.Message == "errors.oidc.creating-user")
{
// The real exception is logged; surface a generic 'account creation failed, contact admin' message.
return StatusCode(500, "Unable to create account. Check server logs.");
} Prevention
- Monitor logs for 'An error occured creating a new user' — it carries the real stack trace.
- Keep the DB reachable and migrations applied before enabling OIDC.
- Ensure the default site theme exists (GetDefaultTheme non-null).
When it happens
Trigger: Any non-KavitaException inside NewUserFromOpenIdConnect during first-time OIDC provisioning: userManager.CreateAsync infra failure, DB constraint violation, null theme from GetDefaultTheme, SeedUser throwing an unexpected exception type.
Common situations: DB unreachable or migration pending; unique-constraint collision (username/email race); default site theme missing; transient DB timeout during account creation.
Related errors
- User is not authenticated
- errors.oidc.no-account
- cannot-change-identity-provider-original-user
- oidc-managed
- errors.oidc.missing-external-id
AI-assisted analysis of Kareadita/Kavita@9c3e540000 (2026-08-13).
Data as JSON: /api/errors/6df15308dac1d1dd.
Report an issue: GitHub.