Copilot commented on code in PR #7879:
URL: https://github.com/apache/opendal/pull/7879#discussion_r3536293474


##########
bindings/python/src/layers/retry.rs:
##########
@@ -82,15 +90,30 @@ impl RetryLayer {
             retry = retry.with_max_times(max_times);
         }
         if let Some(factor) = factor {
+            if !factor.is_finite() || factor < 1.0 {
+                return Err(ConfigInvalid::new_err(
+                    "factor must be a finite value greater than or equal to 
1.0",
+                ));
+            }
             retry = retry.with_factor(factor);
         }
         if jitter {
             retry = retry.with_jitter();
         }
         if let Some(max_delay) = max_delay {
+            if !max_delay.is_finite() || max_delay < 0.0 {
+                return Err(ConfigInvalid::new_err(
+                    "max_delay must be a finite, non-negative number of 
seconds",
+                ));
+            }
             retry = retry.with_max_delay(Duration::from_micros((max_delay * 
1_000_000.0) as u64));
         }
         if let Some(min_delay) = min_delay {
+            if !min_delay.is_finite() || min_delay < 0.0 {
+                return Err(ConfigInvalid::new_err(
+                    "min_delay must be a finite, non-negative number of 
seconds",
+                ));
+            }
             retry = retry.with_min_delay(Duration::from_micros((min_delay * 
1_000_000.0) as u64));
         }

Review Comment:
   `max_delay`/`min_delay` are converted via `(delay * 1_000_000.0) as u64`, 
which truncates sub-microsecond values and also saturates for very large values 
(float-to-int `as` cast), silently changing the requested delay. Since this PR 
is explicitly tightening input validation, it would be more accurate to convert 
via `Duration::try_from_secs_f64(...)` and raise `ConfigInvalid` on 
out-of-range durations instead of silently clamping/truncating.



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