Copilot commented on code in PR #14520:
URL: https://github.com/apache/gravitino/pull/14520#discussion_r4452367571


##########
common/src/main/java/org/apache/gravitino/dto/requests/PolicyCreateRequest.java:
##########
@@ -119,6 +120,9 @@ public void validate() throws IllegalArgumentException {
         StringUtils.isNotBlank(policyType), "\"policyType\" is required and 
cannot be empty");
     Preconditions.checkArgument(
         policyContent != null, "\"content\" is required and cannot be null");
+    // Resolve policyType before content.validate(): Jackson may have fallen 
back to custom content
+    // for an unknown or mis-cased type, and custom content rules would 
obscure the type error.
+    Policy.BuiltInType.fromPolicyType(policyType);

Review Comment:
   With `policyType: "SYSTEM_ICEBERG_COMPACTION"` and `content: 
{"maxPartitionNum": 5}`, Jackson rejects the field on fallback 
`CustomContentDTO` before `validate()` runs, so the response remains `Malformed 
json request` rather than naming the type. Validate the discriminator before 
binding content, preserve the type-specific error in the HTTP response, and add 
nonempty-payload regression tests. The same issue affects `newContent` in 
`PolicyUpdateRequest.java:200`.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to