Xuanwo opened a new pull request, #8911: URL: https://github.com/apache/opendal/pull/8911
# Which issue does this PR close? None. Found during maintenance; no separate issue was filed. # Rationale for this change `ChaosReader::i_feel_lucky` sampled an integer in `0..100` and compared it against `(self.error_ratio * 100.0) as u32`. Truncating `error_ratio * 100.0` to an integer caused two bugs: - Any `error_ratio` in `(0.0, 0.01)` (such as `0.005` or `0.001`) truncated to `0`, so `point >= 0` was always `true` and no errors were ever injected. - Fractional percentages above `0.01` (such as `0.015`) silently truncated down to integer percentages (`1%`). # What changes are included in this PR? - Sample a uniform `f64` in `[0.0, 1.0)` via `rng.random()` in `ChaosReader::i_feel_lucky` and compare `point >= self.error_ratio` directly, preserving full floating-point precision across `[0.0, 1.0]` without changing `ChaosLayer::new` validation. - Add deterministic seeded unit tests covering sub-percent injection (`0.005`), fractional percentages (`0.015` vs `0.01`), and the `0.0` / `1.0` boundaries. # Are there any user-facing changes? `ChaosLayer` now honors sub-percent and fractional `error_ratio` values in `(0.0, 1.0)` instead of truncating them to integer percentages. # Breaking changes # AI Usage Statement - Harness: pi - Model: Gemini 4 Neon - Effort: high - Role: Verified the integer-percent truncation bug, implemented the floating-point comparison fix and deterministic regression tests, and opened this PR. No external assumptions or unverified edge cases remain; existing `ChaosLayer::new` validation (`0.0..=1.0`) is unchanged. -- 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]
