You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I would like to suggest an improvement on how Micronaut Data handles error messages for the following use case.
When using a validated @Embeddable , if:
It has a mandatory field
The result set has a null value for that field
The error message is a bit confusing, as it says that the whole @Embeddable is null/missing. Take for example these data models:
@MappedEntity("my_entity")
public record MyEntity(
@MappedProperty("id") @Id@GeneratedValue@NullableLongid,
@Relation(Relation.Kind.EMBEDDED) @Valid@NotNullAuditFieldsauditFields) {
}
@Embeddablepublic record AuditFields(
@MappedProperty("created_on") @NotNullLocalDatecreatedOn,
@MappedProperty("created_by") @NotBlankStringcreatedBy) {
}
If the DB has a missing/null createdBy field, for instance, this is the error message throw by the repository:
Error instantiating entity [io.github.nahuel92.MyEntity]: Null argument specified for [auditFields]. If this argument is allowed to be null annotate it with @Nullable
This can be improved by making the error message something like this:
Error instantiating entity [io.github.nahuel92.MyEntity]: Null argument specified for [auditFields.createdBy]. If this argument is allowed to be null annotate it with @Nullable
Here's an example app where you can see this in action:
Issue description
Hi there!
I would like to suggest an improvement on how Micronaut Data handles error messages for the following use case.
When using a validated
@Embeddable
, if:The error message is a bit confusing, as it says that the whole
@Embeddable
is null/missing. Take for example these data models:If the DB has a missing/null
createdBy
field, for instance, this is the error message throw by the repository:Error instantiating entity [io.github.nahuel92.MyEntity]: Null argument specified for [auditFields]. If this argument is allowed to be null annotate it with @Nullable
This can be improved by making the error message something like this:
Error instantiating entity [io.github.nahuel92.MyEntity]: Null argument specified for [auditFields.createdBy]. If this argument is allowed to be null annotate it with @Nullable
Here's an example app where you can see this in action:
https://github.com/Nahuel92/poc-projects/tree/master/micronaut/micronaut-data-embedded-misleading-error-message
Thanks!
The text was updated successfully, but these errors were encountered: