Open saw303 opened 1 year ago
Turns out that there was an serialisation introspection missing on type Constraint
.
https://github.com/saw303/m4configuration/compare/micronaut400...micronaut400_fixed
After debugging down the rabbit hole, I found the issue hint in JsonBeanPropertyBinder
So, I guess that's not an actual Micronaut 4.x bug, but as a sort of improvement it would be nice to have a trace log that could be activated to find serialisation issues easier.
@Override
public BindingResult<Object> bind(ArgumentConversionContext<Object> context, Map<CharSequence, ? super Object> source) {
try {
JsonNode objectNode = buildSourceObjectNode(source.entrySet());
Object result = jsonMapper.readValueFromTree(objectNode, context.getArgument());
return () -> Optional.of(result);
} catch (Exception e) {
// add a trace log here. This could be very helpful, when debugging configuration issues.
context.reject(e);
return new BindingResult<Object>() {
@Override
public List<ConversionError> getConversionErrors() {
return CollectionUtils.iterableToList(context);
}
@Override
public boolean isSatisfied() {
return false;
}
@Override
public Optional<Object> getValue() {
return Optional.empty();
}
};
}
}
@n0tl3ss can you look into improving error messages for binding errors in configuration like this
Expected Behavior
Given the following YAML
The immutable configuration should be bound correctly onto the
ConfigurationProperties
interface type.Actual Behaviour
For some reason, I do not understand yet, Micronaut has issues with binding collections onto the ProductConfiguration.
Steps To Reproduce
micronaut394
and run./gradlew check
. All tests will pass.micronaut400
and rerun the same Gradle task. Some tests will fail.Environment Information
Example Application
https://github.com/saw303/m4configuration
Version
4.0.0