Skip to content

fix(valid): reject non-finite percentage and IQR boundaries - #1544

Open
Tyagiquamar wants to merge 1 commit into
bencherdev:develfrom
Tyagiquamar:fix/boundary-reject-infinity
Open

Tyagiquamar wants to merge 1 commit into
bencherdev:develfrom
Tyagiquamar:fix/boundary-reject-infinity

Conversation

@Tyagiquamar

Copy link
Copy Markdown

Summary

Reject non-finite floating point values (positive infinity, negative infinity and NaN) in the percentage and IQR boundary validators. The base Boundary type already rejects non-finite values; the two derived boundary types did not.

Root Cause & Problem

is_valid_percentage_boundary and is_valid_iqr_boundary in lib/bencher_valid/src/model/boundary.rs only checked boundary >= 0.0. Positive infinity satisfies that comparison, so PercentageBoundary::try_from(f64::INFINITY) and IqrBoundary::try_from(f64::INFINITY) succeeded. These types feed model validation and limit computation (Limit::percentage and Limit::iqr), where an infinite boundary produces nonsensical limits such as negative infinity. is_valid_boundary already required is_finite(), so this was an inconsistency between the base type and its derived types.

Technical Solution

Added boundary.is_finite() to both validators. NaN was already rejected by the comparison; infinity is now rejected too. No new dependencies and no API changes.

Test Plan

Added two regression tests in lib/bencher_valid/src/model/boundary.rs covering finite values plus positive infinity, negative infinity and NaN through both the validator functions and the TryFrom<f64> constructors.

All commands ran in Docker with image bencher-rust (derived locally from rust:bookworm) and --memory=1500m:

  • Before the fix, cargo test -p bencher_valid --lib boundary result: FAILED, 4 passed and 2 failed. Both new tests failed, confirming the defect.
  • After the fix, cargo test -p bencher_valid --lib boundary result: ok, 6 passed and 0 failed.
  • cargo test -p bencher_valid --lib result: ok, 113 passed and 0 failed.
  • cargo fmt -p bencher_valid -- --check --config newline_style=Windows result: passed. Windows newline style was used because this checkout is CRLF; CI checks LF on Linux.
  • cargo clippy -p bencher_valid --lib -- -D warnings result: clean, no warnings.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant