Repository navigation
Remove redundant service discovery registration in YARP configuration - #3007
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
fix: remove redundant
AddServiceDiscovery()call inProgram.csProblem
The YARP gateway application crashes on startup with a
NullReferenceExceptioninsideConfigurationServiceEndpointProviderOptionsValidator, preventingMapReverseProxy()from completing. This manifests in Aspire 13.2.x with themcr.microsoft.com/dotnet/nightly/yarp:2.3-previewimage.The root cause is a double registration of service discovery:
Extensions.cs:29—AddServiceDefaults()already callsbuilder.Services.AddServiceDiscovery()internallyProgram.cs:28—AddServiceDiscovery()was called again immediately afterIn older versions of
Microsoft.Extensions.ServiceDiscoverythis was harmless — all internal registrations usedTryAdd*patterns that silently no-op on duplicates. A version shipped with the Aspire 13.2.x image switched at least one registration to a non-idempotentAdd*call, causingConfigurationServiceEndpointProviderOptionsValidatorto be registered twice with a factory whose dependency resolves tonullon the second invocation.Stack trace
Fix
Remove the redundant call from
src/Application/Program.cs:builder.AddServiceDefaults(); - builder.Services.AddServiceDiscovery(); builder.Services.AddReverseProxy() .LoadFromConfig(builder.Configuration.GetSection("ReverseProxy")) .AddServiceDiscoveryDestinationResolver();Impact
2.3-previewimagesAddServiceDefaults()has always registered service discovery; the explicit call was always redundant