Skip to content

fix: reject non-finite retry policy values#274

Open
YunchuWang wants to merge 1 commit into
mainfrom
copilot-finds/bug/retry-policy-nan-validation
Open

fix: reject non-finite retry policy values#274
YunchuWang wants to merge 1 commit into
mainfrom
copilot-finds/bug/retry-policy-nan-validation

Conversation

@YunchuWang

Copy link
Copy Markdown
Member

Summary

Fixes #230

RetryPolicy's constructor validated numeric parameters using comparison
operators (<=, <) which silently accept NaN because all NaN comparisons
return false in JavaScript. For example, NaN <= 0 evaluates to false,
so NaN maxNumberOfAttempts passed validation and caused infinite retries
since attemptCount >= NaN is always false.

Add Number.isFinite() guards before all comparison checks to reject NaN,
Infinity, and -Infinity for all numeric parameters.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings June 18, 2026 17:14

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR tightens RetryPolicy constructor validation to reject non-finite numeric inputs (NaN/±Infinity) so retry scheduling can’t enter invalid or infinite-retry states, addressing issue #230.

Changes:

  • Added Number.isFinite() guards for RetryPolicy numeric options and updated corresponding error messages.
  • Expanded Jest coverage to assert NaN/Infinity rejection across retry policy parameters.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
packages/durabletask-js/src/task/retry/retry-policy.ts Adds finite-number validation for retry policy inputs and updates thrown error messages accordingly.
packages/durabletask-js/test/retry-policy.spec.ts Updates existing validation assertions and adds new tests for NaN/Infinity rejection behavior.

Comment on lines 82 to 86
if (
maxRetryIntervalInMilliseconds !== undefined &&
maxRetryIntervalInMilliseconds !== -1 &&
maxRetryIntervalInMilliseconds < firstRetryIntervalInMilliseconds
(!Number.isFinite(maxRetryIntervalInMilliseconds) || maxRetryIntervalInMilliseconds < firstRetryIntervalInMilliseconds)
) {
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.

[copilot-finds] Bug: RetryPolicy constructor silently accepts NaN and Infinity, enabling infinite retries

3 participants