OrchardCMS/OrchardCore · error · AggregateException
An error occurred while pruning authorizations.
Error message
An error occurred while pruning authorizations.
What it means
OpenIdTokenStore.PruneAsync deletes expired tokens in batches and aggregates any per-batch exceptions. If at least one batch failed, it throws an AggregateException titled 'An error occurred while pruning authorizations.' containing all underlying failures. Note the message mentions authorizations but is thrown by the token store, a copy-paste artifact in the source.
Solutions
- Inspect the InnerExceptions of the AggregateException to find the actual root cause (DB timeout, concurrency, connectivity).
- Re-run the prune operation; it is idempotent since it only deletes expired tokens.
- Verify database health and YesSql store configuration for the tenant running the background task.
- Reduce prune batch pressure by ensuring pruning runs regularly (avoid huge expired-token backlogs) and check tenant logs in App_Data/Sites/{Tenant}/logs for details.
Defensive patterns
Strategy: try-catch
Try / catch
try
{
await tokenStore.PruneAsync(date, ct);
}
catch (AggregateException ex)
{
foreach (var inner in ex.InnerExceptions)
logger.LogError(inner, "Token prune batch failed");
// pruning is idempotent; schedule a retry
} Prevention
- Run the prune background task regularly so expired-token batches stay small.
- Check tenant database connectivity and YesSql configuration before enabling pruning at scale.
- Inspect InnerExceptions rather than the aggregate message for root cause.
- Watch tenant logs under App_Data/Sites/{Tenant}/logs for recurring storage errors.
When it happens
Trigger: Calling PruneAsync (via ITokenStore.PruneAsync, usually from the OpenIddict pruning background task) when deleting expired tokens throws — e.g., YesSql database errors, concurrency conflicts, or query failures during batch removal.
Common situations: Database connectivity issues or timeouts during the periodic cleanup job; a concurrent transaction modifying a token being pruned; YesSql storage backend misconfiguration on a specific tenant; large backlogs of expired tokens making batches hit lock/timeout limits.
Understand the failure class
Background: Database query failed: Internal Server Error 500s wrapping SQL, Prisma, and connection failures — what to check first — this error's family across 16 libraries.
Related errors
- The token was concurrently updated and cannot be persisted…
- The configured table name separator
- The configured identity column size
- Unsupported database provider
- The ' ' could not be persisted and cached as it has been…
AI-assisted analysis of OrchardCMS/OrchardCore@4306c0717f (2026-09-13).
Data as JSON: /api/errors/cff09971ee2f898f.
Report an issue: GitHub.
Appendix: source
Thrown at src/OrchardCore/OrchardCore.OpenId.Core/YesSql/Stores/OpenIdTokenStore.cs:373
try
{
await _session.FlushAsync(cancellationToken);
}
catch (Exception exception)
{
exceptions ??= new List<Exception>(capacity: 1);
exceptions.Add(exception);
continue;
}
result += tokens.Count;
}
if (exceptions != null)
{
throw new AggregateException("An error occurred while pruning authorizations.", exceptions);
}
return result;
}
/// <inheritdoc/>
public virtual async ValueTask<long> RevokeAsync(
string subject, string client, string status, string type, CancellationToken cancellationToken)
{
Expression<Func<OpenIdTokenIndex, bool>> query = index => true;
if (!string.IsNullOrEmpty(subject))
{
Expression<Func<OpenIdTokenIndex, bool>> filter = index => index.Subject == subject;
query = Expression.Lambda<Func<OpenIdTokenIndex, bool>>(
Expression.AndAlso(query.Body, filter.Body), query.Parameters[0]);
}View on GitHub (pinned to 4306c0717f)