dotnet/yarp · critical · NotSupportedException
This version of YARP is incompatible with the current versio
Error message
This version of YARP is incompatible with the current version of ASP.NET Core.
What it means
Thrown by YarpRateLimiterPolicyProvider constructor when reflection cannot retrieve the internal PolicyMap property from RateLimiterOptions. YARP resolves named rate-limiter policies via this internal dictionary; if the property is missing or null, the installed ASP.NET Core version is incompatible with this YARP build. This is the first of two similar guards (PolicyMap).
Source
Thrown at src/ReverseProxy/Configuration/IYarpRateLimiterPolicyProvider.cs:35
{
ValueTask<object?> GetPolicyAsync(string policyName);
}
internal sealed class YarpRateLimiterPolicyProvider : IYarpRateLimiterPolicyProvider
{
private readonly RateLimiterOptions _rateLimiterOptions;
private readonly IDictionary _policyMap, _unactivatedPolicyMap;
public YarpRateLimiterPolicyProvider(IOptions<RateLimiterOptions> rateLimiterOptions)
{
ArgumentNullException.ThrowIfNull(rateLimiterOptions?.Value);
_rateLimiterOptions = rateLimiterOptions.Value;
var type = typeof(RateLimiterOptions);
var flags = BindingFlags.Instance | BindingFlags.NonPublic;
_policyMap = type.GetProperty("PolicyMap", flags)?.GetValue(_rateLimiterOptions, null) as IDictionary
?? throw new NotSupportedException("This version of YARP is incompatible with the current version of ASP.NET Core.");
_unactivatedPolicyMap = type.GetProperty("UnactivatedPolicyMap", flags)?.GetValue(_rateLimiterOptions, null) as IDictionary
?? throw new NotSupportedException("This version of YARP is incompatible with the current version of ASP.NET Core.");
}
public ValueTask<object?> GetPolicyAsync(string policyName)
{
return ValueTask.FromResult(_policyMap[policyName] ?? _unactivatedPolicyMap[policyName]);
}
}
View on GitHub (pinned to bd11867bee)
Solutions
- Match the YARP package version to the ASP.NET Core framework version in use.
- Update both YARP and the ASP.NET Core shared framework to a compatible pair.
- If rate-limiter integration is not needed, remove RateLimiterPolicy from route config to avoid activating the provider.
Example fix
// before — incompatible pairing <PackageReference Include="Yarp.ReverseProxy" Version="2.0.0" /> // targeting net9.0 preview with changed RateLimiterOptions internals // after — use YARP build that supports your framework <PackageReference Include="Yarp.ReverseProxy" Version="2.2.0" />
Defensive patterns
Strategy: validation
Validate before calling
var pm = typeof(RateLimiterOptions).GetProperty("PolicyMap", BindingFlags.Instance | BindingFlags.NonPublic);
if (pm is null) throw new NotSupportedException("YARP/ASP.NET Core rate-limiter incompatibility; align versions."); Type guard
// n/a — reflection-based version check
Try / catch
try { services.AddSingleton<YarpRateLimiterPolicyProvider>(); }
catch (NotSupportedException ex) when (ex.Message.Contains("incompatible"))
{ logger.LogCritical(ex, "Align YARP and ASP.NET Core versions."); throw; } Prevention
- Match YARP and framework versions in lockfile/csproj.
- Avoid RateLimiterPolicy on routes unless versions are verified compatible.
- Add a post-restore test that constructs the provider.
When it happens
Trigger: Constructing YarpRateLimiterPolicyProvider (resolved when RateLimiterPolicy is set on a route) on an ASP.NET Core version where RateLimiterOptions.PolicyMap was removed/renamed/changed, or returned null.
Common situations: ASP.NET Core version skew relative to YARP. Using a framework patch that moved internal members. Preview framework builds with altered rate-limiting internals.
Related errors
- This version of YARP is incompatible with the current versio
- Configuration Filter Error: Substitution for '{lookup}' in c
- Missing required services. Did you call '.AddKubernetesRever
- rate: Wait(count={count}) exceeds limiter's burst {burst}
- The route config format has changed, routes are now objects
AI-assisted analysis of dotnet/yarp@bd11867bee (2026-08-13).
Data as JSON: /api/errors/fe637e7cb207304f.
Report an issue: GitHub.