FrankChen021 commented on code in PR #19412:
URL: https://github.com/apache/druid/pull/19412#discussion_r3234374855


##########
server/src/main/java/org/apache/druid/client/indexing/ClientCompactionRunnerInfo.java:
##########
@@ -241,6 +242,37 @@ public static CompactionConfigValidationResult 
validateMaxNumTasksForMSQ(Map<Str
     return CompactionConfigValidationResult.success();
   }
 
+  /**
+   * Validate that {@link ClientMSQContext#CTX_MINOR_COMPACTION_TASK_PERCENT}, 
if present in context,
+   * is an integer between 1 and 100. Rejects malformed and out-of-range 
values upfront so a bad
+   * config cannot be persisted and then fail every subsequent minor 
compaction job.
+   */
+  public static CompactionConfigValidationResult 
validateMinorCompactionTaskPercentForMSQ(Map<String, Object> context)
+  {
+    if (context == null || 
!context.containsKey(ClientMSQContext.CTX_MINOR_COMPACTION_TASK_PERCENT)) {
+      return CompactionConfigValidationResult.success();
+    }
+    final int percent;
+    try {
+      percent = 
QueryContext.of(context).getInt(ClientMSQContext.CTX_MINOR_COMPACTION_TASK_PERCENT,
 0);

Review Comment:
   [P2] Reject fractional minorCompactionTaskPercent values
   
   This validation uses `QueryContext.getInt`, which accepts any `Number` by 
calling `intValue()`. JSON values like `50.9` deserialize as `Double` and are 
silently truncated to `50`, so malformed configs can be persisted despite the 
new contract requiring an integer between 1 and 100. Please reject non-integral 
`Number` values, or parse with exact integer conversion, before accepting the 
config.



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


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to