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


##########
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:
   This check still runs after Jackson has deserialized `content`. With 
`policyType: "SYSTEM_ICEBERG_COMPACTION"` (or `system_iceberg_bogus`) and 
`content: {"maxPartitionNum": 5}`, the fallback `CustomContentDTO` rejects the 
field first, so the response remains `400 Malformed json request` without 
naming the type. This reproduction from #14428 also affects updates. Could we 
validate the discriminator before deserializing fallback content and add 
create/update regression tests with non-empty built-in content?



-- 
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