Repository navigation
fix: report nested @Valid config violations by full property name - #20898
Conversation
This reverts commit 79ab7f06f929faac50122b1a0853694cbe1e4cba.
FrankChen021
left a comment
There was a problem hiding this comment.
🟢 Approval recommended
No actionable issues found in this review. The nested Bean Validation path traversal correctly resolves the declared nested type, and the tests cover both generic nested configuration and the S3 production binding.
Reviewed 3 of 3 changed files.
This is an automated review by Codex GPT-5.6-Luna(max)
| } else { | ||
| path.append(".").append(pathPart); | ||
| } | ||
| beanClazz = theField.getType(); |
There was a problem hiding this comment.
Optional: this fixes the S3 case, but the walk still throws for shapes it doesn't model, e.g. @Valid List<Inner> items (items=[{"count":0}]) or a nested type whose constrained field is declared on a superclass: both still end in RuntimeException: NoSuchFieldException: count. Falling back to the validator's own path in the catch below keeps the property name in the message for those cases too:
catch (NoSuchFieldException e) {
path = new StringBuilder(violation.getPropertyPath().toString());
}That gives <prefix>.items[0].count - must be greater than or equal to 1 (it loses the @JsonProperty rename for that one violation, which seems fine for an error message).
There was a problem hiding this comment.
this is a generated problem ...would have been better to just avoid the usage of JsonProperty instead of adding any logic like this....
updated it
FrankChen021
left a comment
There was a problem hiding this comment.
🟡 Changes recommended
The fallback prevents crashes for list and inherited nested validations, but it can produce incorrect property names when Jackson aliases are used. Preserve alias-aware paths before merging.
Reviewed 3 of 3 changed files; finding in 1 file. No follow-up thread was supplied; the current-head review is sufficient.
Validation: git diff --check passed. No tests or builds were run.
| Severity | Findings |
|---|---|
| P0 | 0 |
| P1 | 0 |
| P2 | 1 |
| P3 | 0 |
| Total | 1 |
This is an automated review by Codex GPT-5.6-Luna(max)
After addressing the findings or replying to the comments, you can request another review from me to trigger a new automated review.
| } | ||
| catch (NoSuchFieldException e) { | ||
| throw new RuntimeException(e); | ||
| path = new StringBuilder(violation.getPropertyPath().toString()); |
There was a problem hiding this comment.
[P2] Fallback loses Jackson property aliases
Finding: When reflection cannot resolve a list/container or inherited-field segment, the fallback replaces the translated path with Bean Validation's Java-name path. This discards @JsonProperty aliases and can report a non-existent configuration property.
Suggestion: Resolve container and inherited types with Jackson metadata, or preserve translated segments while resolving only the remaining suffix; add an aliased list/inherited-field regression.
🐛 Nested-Violation-Crash
Nested
@Validconstraint fails ->JsonConfiguratorthrows bareRuntimeException(NoSuchFieldException). No property named.🔍 Cause
getDeclaredFieldon root class (JsonConfigurator.java:175)NoSuchFieldException-> rethrown (:193-195)S3StorageConfig->@Valid S3TransferConfig, bound underdruid.storage💥 Before:
druid.storage.transfer.multipartUploadThreshold=0