-
Notifications
You must be signed in to change notification settings - Fork 41.2k
Setting ignoreInvalidFields=true on @ConfigurationProperties causes unknown fields to be ignored as well #22308
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Thanks for the report. This looks like a bug to me. The problem can be reproduced by modifying @ConfigurationProperties(ignoreUnknownFields = false, ignoreInvalidFields = true)
static class IgnoreUnknownFieldsFalseProperties extends BasicProperties {
} With this change in place @Override
public Object onFailure(ConfigurationPropertyName name, Bindable<?> target, BindContext context, Exception error)
throws Exception {
if (error instanceof UnboundConfigurationPropertiesException) {
throw error;
}
return super.onFailure(name, target, context, error);
} Flagging for team attention to double-check my reasoning and discuss which release we should fix this in. |
Exception should be thrown if there are unknown external properties and its corresponding @ConfigurationProperties has attributes 'ignoreUnknownFields' as false and 'ignoreInvalidFields' as true Fixes spring-projectsgh-22308
I had ran into the same issue and I thought it was expected behavior. Open a PR using what @wilkinsona suggested. |
Uh oh!
There was an error while loading. Please reload this page.
Throw an exception
but
It works fine, but I think it's time to throw an exception
The text was updated successfully, but these errors were encountered: