question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Log unknown properties when using @ConfigurationProperties

See original GitHub issue

Enhancement

With YAML properties it’s too easy to corrupt properties, by just adding whitespace. eg:

# incorrect
spring:
  cloud:
    stream:
      input:
        consumer:
          maxAttempts: 5
          group: api
          
# correct
spring:
  cloud:
    stream:
      input:
        consumer:
          maxAttempts: 5
        group: api

If would be great if regardless the ignoreUnknownFields property, Spring Boot could load a WARN 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.

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:16 (16 by maintainers)

github_iconTop GitHub Comments

1reaction
wilkinsonacommented, Nov 3, 2017

Yes. Thank you.

1reaction
jkubrynskicommented, Aug 5, 2017

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:

22:32:14.705 WARN [localhost-startStop-1] b.b.RelaxedDataBinder$RelaxedBeanWrapper : Unknown property found: Invalid property 'bindings[someName].producer.group' of bean class [org.springframework.cloud.stream.config.BindingProperties]: Bean property 'group' is not writable or has an invalid setter method. Did you mean 'group'?
22:32:43.751 WARN [main] b.b.RelaxedDataBinder$RelaxedBeanWrapper : Unknown property found: Invalid property 'bindings[someName].producer.group' of bean class [org.springframework.cloud.stream.config.BindingProperties]: Bean property 'group' is not writable or has an invalid setter method. Did you mean 'group'?
22:32:43.756 WARN [main] b.b.RelaxedDataBinder$RelaxedBeanWrapper : Unknown property found: Invalid property 'bindings[someName].producer.group' of bean class [org.springframework.cloud.stream.config.BindingProperties]: Bean property 'group' is not writable or has an invalid setter method. Did you mean 'group'?
Read more comments on GitHub >

github_iconTop Results From Across the Web

configurationproperties is an unknown property - Stack Overflow
In my application properties file, all of the variables "is an unknown property" with yellow underline. I run the application but the same...
Read more >
Configuring a Spring Boot Module with ... - Reflectoring
An in-depth look at Spring Boot's support to bind external configuration parameters to fields of a Spring bean.
Read more >
IntelliJ – Cannot Resolve Spring Boot Configuration ...
During a build, the annotation processor searches for all classes that are annotated with @ConfigurationProperties. It generates custom property ...
Read more >
Using @ConfigurationProperties in Spring Boot - amitph
In this tutorial we'll learn about mapping the properties file or yaml file into Java Bean using @ConfigurationProperties annotation.
Read more >
Core Features - Spring
Here you can learn about the key features that you may want to use and ... To do so, you need to enable...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found