-
Notifications
You must be signed in to change notification settings - Fork 41.2k
Log unknown properties when using @ConfigurationProperties #9936
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
It's an interesting suggestion but I think it would lead to far too many warnings being generated when a binding target needs IMO, your problem is an argument in favour of using a properties file rather than YAML. Alternatively, your IDE (IDEA, Eclipse, or NetBeans) can already warn you when you use an unknown property. We could, perhaps, consider debug logging if you still feel that would be useful. |
@wilkinsona The problem is that IDE cannot notify about the properties I've mentioned. The only way to solve it during runtime binding. I prefer YAML instead of properties as it is much easier to read and it has a nice structure. I'm not saying to enable it by default, but maybe it could be a parameter set on SpringBootApplication? |
It feels much too specialised (and, given the lilkelihood of false positives, only really useful for debugging purposes) to warrant an attribute on |
Most projects I've seen keep properties in the separate repository than the application. So you have different properties for production than for staging. I'm not sure if many people enable debug logging on production. INFO would be OK, because I can configure filters in ELK stack to figure out such issues. |
It would be debug logging for one specific logger that only reported what you're asking for here.
Info doesn't help. It's output by default and I believe there would be too many false positives to be generally useful. |
I'll check in our applications how many properties are reported, and then I'll get back to you. |
For the record I agree with Andy. I guess it can't tell you because the target is a map and group is just a key? If I misunderstood, can you please clarify why the ide can't tell you. Also some IDE shows keys of a map in a different font to let you know what type it is. All in all I do not think Spring Boot can/should attempt to fix those potential mistakes. |
It's not a map -> it's a
So to sum up -> if you know how to solve above in different way than you using Spring Boot please let me know. But please take care about people who use your product on production and not only during conference talks. |
To suggest that we only care about people using Spring Boot during conference talks purely because we're not keen on something you've proposed is both rude and ridiculous. If we didn't care this issue would already have been closed rather than the team replying to you four times already today.
Thank you. That would be a useful data point that might allow us to make some constructive progress. If it becomes apparent that there's some useful information that can be determined at runtime then we can think about how to surface that information. IMO, for the information to be useful it will have to be largely free of false-positives and I have a hunch that that is unlikely to be the case. |
I've opened #9945 to explore the possibility of improving the metadata generation (the first step towards the IDE warning about unknown properties). |
@wilkinsona The metadata won't help in real-world use cases, because then you keep properties in different repository than the application. |
@jkubrynski It may not help with your specific use case, but that does not mean that it will be of no help in all real-world use cases. Can we please try to focus on moving this issue forwards? I'm still interested in the data that you offered to collect. |
Of course, it's better to have such properties included in the metadata than not. However please keep in mind, that a lot of production systems keep properties in the separate repository than the application source code. The IDE plugin doesn't use metadata in non-java projects so it can be used only during development. Often even the operation teams manage those properties directly, using vi instead of the Intellij. So the very first moment to verify the properties is during the application startup - in such case the sooner the better. In my opinion, WARN is adequate to seriousness of the situation, but of course if I must choose between DEBUG and nothing I prefer DEBUG. I've checked our applications and currently, there are no invalid properties. We include over 15 different Spring Boot & Spring Cloud starters. However, the problem I found is that after adding unknown property it's logged 3 times:
|
Superseded by #10030 which is our preferred way to tackle this problem. |
@wilkinsona Meant to close? |
Yes. Thank you. |
Enhancement
With YAML properties it's too easy to corrupt properties, by just adding whitespace. eg:
If would be great if regardless the
ignoreUnknownFields
property, Spring Boot could load aWARN
that unmatched property was found. I think that will preserve many stupid mistakes people are making. I can possibly do a PR if you agree it should be implemented.The text was updated successfully, but these errors were encountered: