Skip to content

Validate missing threshold inputs for length and comparison assertions#152

Merged
selkamand merged 1 commit intomainfrom
codex/improve-error-messages-for-nan-thresholds
Feb 12, 2026
Merged

Validate missing threshold inputs for length and comparison assertions#152
selkamand merged 1 commit intomainfrom
codex/improve-error-messages-for-nan-thresholds

Conversation

@selkamand
Copy link
Owner

@selkamand selkamand commented Feb 11, 2026

Motivation

  • Improve error messages when callers pass NA/NaN as threshold arguments to length/comparison assertions by surfacing clear assertion errors.
  • Centralize and harden threshold validation for numeric comparison assertions so comparisons never execute with missing/non-finite thresholds.
  • Ensure helper predicates return strict logical scalars so downstream checks behave deterministically.

Description

  • Added explicit missing/NaN guards to all assert_length*() variants so length = NA/NaN returns "'length' must not be missing" rather than causing missing value where TRUE/FALSE needed (changes in R/assert_length.R).
  • Introduced validate_minimum, validate_maximum, and validate_between_thresholds small validators and wired them into comparison assertion chains (assert_all_* and assert_between/assert_all_between) to validate minimum, maximum, and inclusive before comparisons (changes in R/assert_compare.R).
  • Hardened is_whole_number() to return a strict logical scalar and treat missing/non-finite/non-scalar values as FALSE (change in R/is_functions.R).
  • Added regression tests covering missing length, minimum, maximum, and updated is_whole_number() expectations (changes in tests/testthat/), and updated NEWS.md to document the user-visible behavior fix.

Testing

  • Ran devtools::document() successfully to update docs.
  • Ran devtools::test() and all tests passed after fixes (final test run reported all tests passing).
  • Ran devtools::check(); package build and checks executed but R CMD check reported one warning about missing system qpdf and one note about time verification, causing devtools::check() to exit with a non-zero status due to the warning; the code changes themselves did not produce R errors during checks.
  • Performed targeted runtime spot-checks via devtools::load_all() for assert_length(..., NaN), assert_greater_than(..., NaN), and assert_between(..., maximum = NaN) which returned the new informative assertion messages as expected.

Codex Task

@selkamand selkamand linked an issue Feb 12, 2026 that may be closed by this pull request
@selkamand selkamand merged commit ddd542c into main Feb 12, 2026
7 checks passed
@selkamand selkamand deleted the codex/improve-error-messages-for-nan-thresholds branch February 12, 2026 09:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Bad error message when threshold values are missing

1 participant