Skip to content

fix: reject non-finite retry policy values#274

Merged
YunchuWang merged 2 commits into
mainfrom
copilot-finds/bug/retry-policy-nan-validation
Jun 25, 2026
Merged

fix: reject non-finite retry policy values#274
YunchuWang merged 2 commits 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 thread packages/durabletask-js/src/task/retry/retry-policy.ts
Validate RetryPolicy maxRetryIntervalInMilliseconds after applying the default value so firstRetryIntervalInMilliseconds cannot exceed the resolved max interval.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Comment thread packages/durabletask-js/src/task/retry/retry-policy.ts
Comment thread packages/durabletask-js/src/task/retry/retry-policy.ts
@YunchuWang YunchuWang merged commit b1f039a into main Jun 25, 2026
28 checks passed
@YunchuWang YunchuWang deleted the copilot-finds/bug/retry-policy-nan-validation branch June 25, 2026 15:42
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

4 participants