Skip to content

Fix NaN handling in responseAdSlotCount - #1254

Open
pavankumar-vh wants to merge 1 commit into
CodebuffAI:mainfrom
pavankumar-vh:fix/response-ad-positions-validation
Open

Fix NaN handling in responseAdSlotCount#1254
pavankumar-vh wants to merge 1 commit into
CodebuffAI:mainfrom
pavankumar-vh:fix/response-ad-positions-validation

Conversation

@pavankumar-vh

Copy link
Copy Markdown

Overview

Fix NaN handling in the responseAdSlotCount function in common/src/util/response-ad-positions.ts.

Bug Description

The function didn't validate that params.step and params.firstAdAfterNodes are finite numbers. If they were NaN or Infinity, Math.max(1, NaN) would return NaN.

Fix

Added Number.isFinite() checks to default to safe values for invalid numbers.

Testing

No existing tests for this function, but the fix prevents incorrect behavior with invalid inputs.

Files Changed

  • common/src/util/response-ad-positions.ts - Added NaN validation

Scope

This change only touches common/ which is an approved contribution area per the Contributing Guide.

The function didn't validate that params.step and params.firstAdAfterNodes are
finite numbers. If they were NaN or Infinity, Math.max(1, NaN) would return NaN.

Added Number.isFinite() checks to default to safe values for invalid numbers.
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