Skip to content

fix: Add parseInt validation and remove unused environment variable#24111

Open
hobostay wants to merge 1 commit intoanthropics:mainfrom
hobostay:fix/parseInt-validation-and-cleanup
Open

fix: Add parseInt validation and remove unused environment variable#24111
hobostay wants to merge 1 commit intoanthropics:mainfrom
hobostay:fix/parseInt-validation-and-cleanup

Conversation

@hobostay
Copy link

@hobostay hobostay commented Feb 8, 2026

Summary

This PR includes two bug fixes for the scripts:

  1. Add NaN validation for parseInt operations in backfill-duplicate-comments.ts

    • Previously, invalid environment variable values (e.g., MAX_ISSUE_NUMBER="invalid") would silently become NaN, causing unexpected script behavior
    • Now validates that parsed numbers are valid and within reasonable ranges
    • Throws descriptive error messages for invalid inputs
  2. Remove unused STATSIG_API_KEY from auto-close-duplicates.yml workflow

    • The environment variable was set but never used by the auto-close-duplicates.ts script
    • Removes confusion about unused configuration

Changes

scripts/backfill-duplicate-comments.ts

  • Added validation after parseInt() operations to ensure values are not NaN
  • Added validation to ensure MIN_ISSUE_NUMBER is at least 1
  • Added validation to ensure MAX_ISSUE_NUMBER is greater than MIN_ISSUE_NUMBER
  • Error messages now include the invalid value for easier debugging

.github/workflows/auto-close-duplicates.yml

  • Removed STATSIG_API_KEY environment variable (unused)

Test plan

  • Script now throws descriptive errors for invalid MAX_ISSUE_NUMBER or MIN_ISSUE_NUMBER values
  • Script validates that MIN_ISSUE_NUMBER >= 1
  • Script validates that MAX_ISSUE_NUMBER > MIN_ISSUE_NUMBER
  • Workflow configuration no longer includes unused environment variable

Example Error Messages

MAX_ISSUE_NUMBER must be a valid number. Got: "invalid"
MIN_ISSUE_NUMBER must be at least 1. Got: 0
MAX_ISSUE_NUMBER must be greater than MIN_ISSUE_NUMBER. Got: MIN=100, MAX=50

🤖 Generated with Claude Code

This commit includes two bug fixes:

1. Add NaN validation for parseInt operations in backfill-duplicate-comments.ts
   - Previously, invalid environment variable values would silently become NaN
   - Now validates that parsed numbers are valid and within reasonable ranges
   - Throws descriptive error messages for invalid inputs

2. Remove unused STATSIG_API_KEY from auto-close-duplicates.yml workflow
   - The environment variable was set but never used by the script
   - Removes confusion about unused configuration

These changes improve script reliability and make errors easier to diagnose.

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
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