You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Configuration binding swallows the conversion exception #73915
Looks there are some places in the ConfigurationBinder.cs which we swallow the exception. We may consider using BinderOptions.ErrorOnUnknownConfiguration in such places and allow throwing there.
Is there NEAREST Future milestone ?
You ship the application documenting all the configuration options and have no chance to validate them at runtime.
No observability at all
Sounds like a blocker issue.
BTW, don't you have static code analysis as build-pipeline step ? Sonar has no issue to catch this violation
I just wasted 4 hours debugging until I arrived at this issue. I agree with @jvmlet that this should be a blocker and at the very minimum a binding option should be provided to fail on children error.
I'm happy to look at this as I vaguely remember adding ErrorOnUnknownConfiguration. I'm guessing there's no real urgency for this as time is a bit short at the moment.
/// <summary>/// When false (the default), no exceptions are thrown when a configuration key is found for which the/// provided model object does not have an appropriate property which matches the key's name./// When true, an <see cref="System.InvalidOperationException"/> is thrown with a description/// of the missing properties./// </summary>
So, technically, in this case, the key exists, and the config exists, so 🙈
Of course, that config option implies that an error should be thrown, not just on missing properties in config, but also invalid properties in config.
By making ErrorOnUnknownConfiguration dual-purpose might now introduce unexpected breaking changes.
Maybe we need another property named ErrorOnInvalidConfiguration.
What do you think? Would this require another API Proposal?
I don't think we need to complicate the options by adding one more property like that. We can use ErrorOnUnknownConfiguration and clarify the documentation. Yes, it will be a breaking change, but I don't think anyone using ErrorOnUnknownConfiguration was not trying to catch all thrown exception when loading the configuration. Let me know if you think otherwise.
Activity
tarekgh commentedon Aug 15, 2022
Looks there are some places in the ConfigurationBinder.cs which we swallow the exception. We may consider using
BinderOptions.ErrorOnUnknownConfigurationin such places and allow throwing there.runtime/src/libraries/Microsoft.Extensions.Configuration.Binder/src/ConfigurationBinder.cs
Line 614 in 8be2105
runtime/src/libraries/Microsoft.Extensions.Configuration.Binder/src/ConfigurationBinder.cs
Line 647 in 8be2105
runtime/src/libraries/Microsoft.Extensions.Configuration.Binder/src/ConfigurationBinder.cs
Line 696 in 8be2105
runtime/src/libraries/Microsoft.Extensions.Configuration.Binder/src/ConfigurationBinder.cs
Line 755 in 8be2105
We may consider the fix in the future releases.
jvmlet commentedon Aug 16, 2022
Is there NEAREST Future milestone ?

You ship the application documenting all the configuration options and have no chance to validate them at runtime.
No observability at all
Sounds like a blocker issue.
BTW, don't you have static code analysis as build-pipeline step ? Sonar has no issue to catch this violation
fnajera-rac-de commentedon Oct 5, 2022
I just wasted 4 hours debugging until I arrived at this issue. I agree with @jvmlet that this should be a blocker and at the very minimum a binding option should be provided to fail on children error.
jvmlet commentedon Oct 5, 2022
@tarekgh , would you please prioritize it ?
tarekgh commentedon Oct 5, 2022
@jvmlet I marked with the next release milestone. Are you interested in submitting a PR for it?
SteveDunn commentedon Oct 31, 2022
I'm happy to look at this as I vaguely remember adding
ErrorOnUnknownConfiguration. I'm guessing there's no real urgency for this as time is a bit short at the moment.SteveDunn commentedon Oct 31, 2022
The comments for
ErrorOnUnknownConfigurationsay:So, technically, in this case, the key exists, and the config exists, so 🙈
Of course, that config option implies that an error should be thrown, not just on missing properties in config, but also invalid properties in config.
By making
ErrorOnUnknownConfigurationdual-purpose might now introduce unexpected breaking changes.Maybe we need another property named
ErrorOnInvalidConfiguration.What do you think? Would this require another API Proposal?
tarekgh commentedon Nov 1, 2022
I don't think we need to complicate the options by adding one more property like that. We can use
ErrorOnUnknownConfigurationand clarify the documentation. Yes, it will be a breaking change, but I don't think anyone usingErrorOnUnknownConfigurationwas not trying to catch all thrown exception when loading the configuration. Let me know if you think otherwise.tarekgh commentedon Nov 8, 2022
This is already done by the PR #77708