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


##########
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:
   Good catch — `validate()` never ran for that case because Jackson had 
already failed while reading `content` as `CustomContentDTO`.
   
   Addressed in df1dcad53:
   - `PolicyCreateRequestDeserializer` / 
`PolicyUpdateContentRequestDeserializer` resolve `policyType` via 
`PolicyWireContentTypes` **before** deserializing `content` / `newContent`
   - Mis-cased / unknown `system_*` types with non-empty built-in content (e.g. 
`SYSTEM_ICEBERG_COMPACTION` + `{"maxPartitionNum":5}`) now return a type-named 
400 instead of `Malformed json request`
   - `JsonMappingExceptionMapper` surfaces a plain `IllegalArgumentException` 
cause when present
   - Create/update regression coverage added for empty and non-empty built-in 
content
   
   `Policy.BuiltInType.fromPolicyType` is unchanged from before this PR (still 
case-insensitive).



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