Skip to content
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

TimeConverterRegistrar silenly ignores incovertible config properties on injection #11385

Open
sdedic opened this issue Nov 27, 2024 · 0 comments

Comments

@sdedic
Copy link

sdedic commented Nov 27, 2024

Expected Behavior

A message like the following should appear in the log/exception messages:

Unable to convert value [60 seconds] to target type [Duration] due to: Unparseable date format (60 seconds). Should either be a ISO-8601 duration or a round number followed by the unit type

which is informative & points out the root cause.

Actual Behaviour

The following message/exception apears:

Error resolving property value [${health-check-cache-expiration}]. Property doesn't exist 

The TimeConverterRegistrar rejects other malformed specifications, like 60us with an appropriate message, but completely misformatted values are silently ignored and misreported as missing. Other malformed inputs, like integers in i.e. micronaut.server.port report a conversion error / invalid property format.

I believe the reason is that when TimeConverterRegistrar rejects the text with the initial regexp check, it does not call context.reject() unlike the other validations.

TimeConverterRegistrar also accepts some malformed inputs without any errors:

  • 60hs - interprets as 60 hours
  • 60ds - interprets as 60 days

Steps To Reproduce

  1. Have a configuraton bean with
@Value("${health-check-cache-expiration}")
private Duration healthCheckCacheExpiration;
  1. Have an application with
healthCheckCacheExpiration: 60 seconds

(converting a service from a dropwizard-based implementation, so different conversion formats were used, and remained in the config)

  1. attempt to inject (otherwise materialize) the configuration bean, so the value is injected and converted from the configuration.

Environment Information

  • Ubuntu Linux 22.04
  • OpenJDK Runtime Environment (build 21+35-2513)

Example Application

No response

Version

4.6.5

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: No status
Development

No branches or pull requests

1 participant