dotnet/yarp · critical · ArgumentException
At least one IProxyConfigProvider is required.
Error message
At least one IProxyConfigProvider is required.
What it means
The `ProxyConfigManager` constructor requires at least one `IProxyConfigProvider` to be registered in the DI container. YARP's configuration model is entirely driven by config providers (e.g., `LoadFromConfig`, `InMemoryConfigProvider`, or custom implementations). If none are registered, the proxy has no routes or clusters and cannot function, so construction fails immediately with an `ArgumentException`.
Source
Thrown at src/ReverseProxy/Management/ProxyConfigManager.cs:103
ArgumentNullException.ThrowIfNull(configChangeListeners);
ArgumentNullException.ThrowIfNull(destinationResolver);
_logger = logger;
_providers = providers.ToArray();
_clusterChangeListeners = clusterChangeListeners.ToArray();
_filters = filters.ToArray();
_configValidator = configValidator;
_proxyEndpointFactory = proxyEndpointFactory;
_transformBuilder = transformBuilder;
_httpClientFactory = httpClientFactory;
_activeHealthCheckMonitor = activeHealthCheckMonitor;
_clusterDestinationsUpdater = clusterDestinationsUpdater;
_destinationResolver = destinationResolver;
_configChangeListeners = configChangeListeners.ToArray();
if (_providers.Length == 0)
{
throw new ArgumentException($"At least one {nameof(IProxyConfigProvider)} is required.", nameof(providers));
}
_configs = new ConfigState[_providers.Length];
_conventions = new List<Action<EndpointBuilder>>();
DefaultBuilder = new ReverseProxyConventionBuilder(_conventions);
_endpointsChangeToken = new CancellationChangeToken(_endpointsChangeSource.Token);
}
public ReverseProxyConventionBuilder DefaultBuilder { get; }
// EndpointDataSource
/// <inheritdoc/>
public override IReadOnlyList<Endpoint> Endpoints
{
getView on GitHub (pinned to bd11867bee)
Solutions
- Call `.LoadFromConfig(builder.Configuration.GetSection("ReverseProxy"))` after `AddReverseProxy()` to register the configuration-based provider.
- Alternatively, call `.LoadFromMemory(routes, clusters)` to provide routes and clusters programmatically.
- If using a custom `IProxyConfigProvider`, register it with `services.AddSingleton<IProxyConfigProvider, MyCustomProvider>()` before the proxy starts.
- Verify in `Program.cs` that the `AddReverseProxy()` chain includes at least one config-loading method before `app.Run()`.
Example fix
// before — no config provider registered, throws at startup
builder.Services.AddReverseProxy();
// after — load from appsettings.json
builder.Services
.AddReverseProxy()
.LoadFromConfig(builder.Configuration.GetSection("ReverseProxy"));
// or load from memory
builder.Services
.AddReverseProxy()
.LoadFromMemory(myRoutes, myClusters); Defensive patterns
Strategy: validation
Validate before calling
// After AddReverseProxy, verify a provider is registered
var providers = builder.Services.Where(s => s.ServiceType == typeof(IProxyConfigProvider)).ToList();
if (providers.Count == 0)
throw new InvalidOperationException("AddReverseProxy requires at least one config provider via LoadFromConfig or LoadFromMemory"); Type guard
// No type guard — this is a DI registration completeness check.
Try / catch
// Not applicable — this is a startup-time validation error. // Fix by registering a config provider.
Prevention
- Always chain `.LoadFromConfig(...)` or `.LoadFromMemory(...)` after `.AddReverseProxy()`.
- Add a startup assertion that verifies at least one IProxyConfigProvider is registered.
- Review Program.cs after refactoring to ensure the config-loading chain is intact.
When it happens
Trigger: `services.AddReverseProxy()` is called but no `.LoadFromConfig(...)` or `.LoadFromMemory(...)` follows it before the application starts. The `ProxyConfigManager` receives an empty `IProxyConfigProvider[]` array from DI and throws at line 103. This surfaces as a startup crash during service resolution.
Common situations: A developer adds `AddReverseProxy()` during initial scaffolding but hasn't yet wired up a config source. A developer writes a custom config provider but forgets to register it in DI. Someone removes the `.LoadFromConfig(configuration)` call while refactoring Program.cs.
Related errors
- The route config format has changed, routes are now objects
- Unable to load or apply the proxy configuration.
- ConfigureHttpClient will override the custom IForwarderHttpC
- Configuration Filter Error: Substitution for '{lookup}' in c
- Missing required services. Did you call '.AddKubernetesRever
AI-assisted analysis of dotnet/yarp@bd11867bee (2026-08-13).
Data as JSON: /api/errors/ebf863fbfeec5c8d.
Report an issue: GitHub.