Repository navigation
Fix NaN handling in file read limits - #1239
pavankumar-vh wants to merge 1 commit into
Conversation
The function didn't validate that remainingChars and remainingTokens are finite numbers. If they were NaN or Infinity, Math.max(0, NaN) would return NaN, causing incorrect calculations. Added Number.isFinite() checks to default to 0 for invalid numbers.
|
Thanks for the contribution. The change itself is small and harmless: guarding A few concerns before this is worth porting:
If you can point to where invalid values originate (e.g., a division somewhere upstream producing |
|
Marking this stale - there has been no activity here for 29 days. It will close in 7 days unless someone comments. This is backlog upkeep, not a verdict on the pull request. A single comment keeps it open, and anything closed this way can be reopened. |
|
Closing this as stale - no activity since it was flagged 7 days ago. Reopen it any time if it is still relevant; that is not a hassle and we would rather have it open than lost. Closed automatically by the community triage bot. If this is wrong, reopen the issue or reply and a maintainer will take another look. |
Overview
Fix NaN handling in file read limits in
common/src/util/file-read-limits.ts.Bug Description
The function didn't validate that remainingChars and remainingTokens are finite numbers. If they were NaN or Infinity,
Math.max(0, NaN)would return NaN, causing incorrect calculations.Fix
Added
Number.isFinite()checks to default to 0 for invalid numbers.Testing
No existing tests for this function, but the fix prevents incorrect behavior with invalid inputs.
Files Changed
common/src/util/file-read-limits.ts- Added NaN validationScope
This change only touches
common/which is an approved contribution area per the Contributing Guide.