Skip to content

Use Number.isNaN instead of global isNaN in saxy XML parser - #1235

Open
pavankumar-vh wants to merge 1 commit into
CodebuffAI:mainfrom
pavankumar-vh:fix/saxy-isnan-type-safety
Open

Use Number.isNaN instead of global isNaN in saxy XML parser#1235
pavankumar-vh wants to merge 1 commit into
CodebuffAI:mainfrom
pavankumar-vh:fix/saxy-isnan-type-safety

Conversation

@pavankumar-vh

Copy link
Copy Markdown

Overview

Fix type safety issue in common/src/util/saxy.ts by using Number.isNaN instead of the global isNaN function.

Bug Description

The global isNaN() function coerces non-numbers to numbers first, which can lead to unexpected results.

Fix

Changed isNaN(value) to Number.isNaN(value) for more predictable and safer type checking.

Testing

No existing tests for this function, but the fix improves type safety.

Files Changed

  • common/src/util/saxy.ts - Use Number.isNaN instead of global isNaN

Scope

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

The global isNaN() function coerces non-numbers to numbers first, which can
lead to unexpected results. Using Number.isNaN is more predictable and safer
for type checking.
@codebuff-team

Copy link
Copy Markdown
Contributor

Correct and safe change: value here is always a number (from parseInt), so Number.isNaN behaves identically to isNaN in this specific call site — there's no actual bug being fixed, just tightened type safety and avoidance of implicit coercion, which is a reasonable defensive practice and matches common lint rules (e.g. no-restricted-globals for isNaN).

The change is minimal, in scope (common/), and low risk. It won't change behavior today, but it guards against future misuse where value might not be a number. Worth porting as a small hygiene fix, though it's a very small contribution on its own — if you're looking to make a larger impact, consider scanning saxy.ts and other common/ utils for other instances of global isNaN/isFinite and batching them into one PR, which is easier for maintainers to review at once.

@codebuff-team codebuff-team added bot:triaged Classified by the community triage bot pr:port-candidate Worth porting into the private source tree labels Sep 3, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bot:triaged Classified by the community triage bot pr:port-candidate Worth porting into the private source tree

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants