Repository navigation
Configuration binding ignores ErrorOnUnknownConfiguration and throws #98231
Description
Activity
- ghost addeduntriagedNew issue has not been triaged by the area ownerNew issue has not been triaged by the area owner
on Feb 9, 2024 Regression?
I haven't tested, but I assume so, since this was the reason for the breaking change.To clarify, this is not a regression. The current behavior is same as pervious .NET versions behavior.
It looks we missed the case that is using type converters. we need to handle the cases when calling
TryConvertValueto checkErrorOnUnknownConfigurationbefore throwing.runtime/src/libraries/Microsoft.Extensions.Configuration.Binder/src/ConfigurationBinder.cs
Line 312 in a79c62d
throw error;
runtime/src/libraries/Microsoft.Extensions.Configuration.Binder/src/ConfigurationBinder.cs
Line 923 in a79c62d
throw error; - ghost removeduntriagedNew issue has not been triaged by the area ownerNew issue has not been triaged by the area owner
on Feb 9, 2024 @tarekgh Hello, any update on this item? Do you have timeline for this fix?
Reacted by Vivin Joy and Mayank Kumar@galakt We currently have higher-priority tasks at hand. If you're interested in submitting a pull request for those, we welcome your contribution.
We are also running into this issue and can potentially help fix it with some guidance, if no one else is working on this
Reacted by Vivin JoyCan we also get this breaking change for .Net 8 documentation changed? It's currently the same behavior as in .Net 6, where type mismatch errors during configuration binding always throws an error by default.
@krmayankk feel free to submit a PR if you are interested. My comment #98231 (comment) explain what need to be done I guess.
Triage: we may investigate and potentially fix in future.
- added a commit that references this issue
on Aug 6, 2026 - addedin-prThere is an active PR which will close this issue when it is mergedThere is an active PR which will close this issue when it is merged
on Aug 6, 2026
Description
According to a breaking change in .NET 8, configuration binding should throw an
InvalidOperationExceptionif the value in the configuration can't be converted to the type of value in the model.To avoid this behavior, the documentation mentions that you can avoid this by setting
BinderOptions.ErrorOnUnknownConfigurationtofalse.This does not work, though, and an exception is thrown when the configuration value can't be converted to the type in the model.
Reproduction Steps
Expected behavior
No exception thrown, according to description in https://learn.microsoft.com/en-us/dotnet/core/compatibility/extensions/8.0/configurationbinder-exceptions#recommended-action.
Actual behavior
Exception thrown when trying to bind configuration to options instance. This will also occur when using
.Configure<TOptions>and usingIOptions<TOptions>via the DI framework.Regression?
I haven't tested, but I assume so, since this was the reason for the breaking change.
Known Workarounds
No response
Configuration
.NET 8.0.0
Windows 11
x64
Other information
Related issue: #73915