{"record":{"id":"fe637e7cb207304f","repo":"dotnet/yarp","slug":"this-version-of-yarp-is-incompatible-with-the-curr-fe637e","errorCode":null,"errorMessage":"This version of YARP is incompatible with the current version of ASP.NET Core.","messagePattern":"This version of YARP is incompatible with the current version of ASP\\.NET Core\\.","errorType":"exception","errorClass":"NotSupportedException","httpStatus":null,"severity":"critical","filePath":"src/ReverseProxy/Configuration/IYarpRateLimiterPolicyProvider.cs","lineNumber":35,"sourceCode":"{\n    ValueTask<object?> GetPolicyAsync(string policyName);\n}\n\ninternal sealed class YarpRateLimiterPolicyProvider : IYarpRateLimiterPolicyProvider\n{\n    private readonly RateLimiterOptions _rateLimiterOptions;\n\n    private readonly IDictionary _policyMap, _unactivatedPolicyMap;\n\n    public YarpRateLimiterPolicyProvider(IOptions<RateLimiterOptions> rateLimiterOptions)\n    {\n        ArgumentNullException.ThrowIfNull(rateLimiterOptions?.Value);\n        _rateLimiterOptions = rateLimiterOptions.Value;\n\n        var type = typeof(RateLimiterOptions);\n        var flags = BindingFlags.Instance | BindingFlags.NonPublic;\n        _policyMap = type.GetProperty(\"PolicyMap\", flags)?.GetValue(_rateLimiterOptions, null) as IDictionary\n            ?? throw new NotSupportedException(\"This version of YARP is incompatible with the current version of ASP.NET Core.\");\n        _unactivatedPolicyMap = type.GetProperty(\"UnactivatedPolicyMap\", flags)?.GetValue(_rateLimiterOptions, null) as IDictionary\n            ?? throw new NotSupportedException(\"This version of YARP is incompatible with the current version of ASP.NET Core.\");\n    }\n\n    public ValueTask<object?> GetPolicyAsync(string policyName)\n    {\n        return ValueTask.FromResult(_policyMap[policyName] ?? _unactivatedPolicyMap[policyName]);\n    }\n}\n","sourceCodeStart":17,"sourceCodeEnd":45,"githubUrl":"https://github.com/dotnet/yarp/blob/bd11867bee7df522e7fd3effb08a9c85fd616908/src/ReverseProxy/Configuration/IYarpRateLimiterPolicyProvider.cs#L17-L45","documentation":"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).","triggerScenarios":"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.","commonSituations":"ASP.NET Core version skew relative to YARP. Using a framework patch that moved internal members. Preview framework builds with altered rate-limiting internals.","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."],"exampleFix":"// before — incompatible pairing\n<PackageReference Include=\"Yarp.ReverseProxy\" Version=\"2.0.0\" />\n// targeting net9.0 preview with changed RateLimiterOptions internals\n// after — use YARP build that supports your framework\n<PackageReference Include=\"Yarp.ReverseProxy\" Version=\"2.2.0\" />","handlingStrategy":"validation","validationCode":"var pm = typeof(RateLimiterOptions).GetProperty(\"PolicyMap\", BindingFlags.Instance | BindingFlags.NonPublic);\nif (pm is null) throw new NotSupportedException(\"YARP/ASP.NET Core rate-limiter incompatibility; align versions.\");","typeGuard":"// n/a — reflection-based version check","tryCatchPattern":"try { services.AddSingleton<YarpRateLimiterPolicyProvider>(); }\ncatch (NotSupportedException ex) when (ex.Message.Contains(\"incompatible\"))\n{ logger.LogCritical(ex, \"Align YARP and ASP.NET Core versions.\"); throw; }","preventionTips":["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."],"tags":["version-compat","rate-limiting","reflection","aspnetcore","startup"],"backgroundTag":null,"analyzedSha":"bd11867bee7df522e7fd3effb08a9c85fd616908","analyzedAt":"2026-08-13T21:29:49.359Z","schemaVersion":2},"datasetVersion":"2026-08-14T00:17:13.853Z"}