Repository navigation
fix(valid): reject non-finite percentage and IQR boundaries - #1544
Open
Tyagiquamar wants to merge 1 commit into
Open
Tyagiquamar wants to merge 1 commit into
Tyagiquamar wants to merge 1 commit into
Conversation
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Reject non-finite floating point values (positive infinity, negative infinity and NaN) in the percentage and IQR boundary validators. The base
Boundarytype already rejects non-finite values; the two derived boundary types did not.Root Cause & Problem
is_valid_percentage_boundaryandis_valid_iqr_boundaryinlib/bencher_valid/src/model/boundary.rsonly checkedboundary >= 0.0. Positive infinity satisfies that comparison, soPercentageBoundary::try_from(f64::INFINITY)andIqrBoundary::try_from(f64::INFINITY)succeeded. These types feed model validation and limit computation (Limit::percentageandLimit::iqr), where an infinite boundary produces nonsensical limits such as negative infinity.is_valid_boundaryalready requiredis_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.rscovering finite values plus positive infinity, negative infinity and NaN through both the validator functions and theTryFrom<f64>constructors.All commands ran in Docker with image
bencher-rust(derived locally fromrust:bookworm) and--memory=1500m:cargo test -p bencher_valid --lib boundaryresult: FAILED, 4 passed and 2 failed. Both new tests failed, confirming the defect.cargo test -p bencher_valid --lib boundaryresult: ok, 6 passed and 0 failed.cargo test -p bencher_valid --libresult: ok, 113 passed and 0 failed.cargo fmt -p bencher_valid -- --check --config newline_style=Windowsresult: passed. Windows newline style was used because this checkout is CRLF; CI checks LF on Linux.cargo clippy -p bencher_valid --lib -- -D warningsresult: clean, no warnings.