Skip to content

[jsweep] Clean check_rate_limit.cjs#18970

Merged
pelikhan merged 2 commits intomainfrom
jsweep/clean-check-rate-limit-ced84f749153f701
Mar 1, 2026
Merged

[jsweep] Clean check_rate_limit.cjs#18970
pelikhan merged 2 commits intomainfrom
jsweep/clean-check-rate-limit-ced84f749153f701

Conversation

@github-actions
Copy link
Copy Markdown
Contributor

@github-actions github-actions bot commented Mar 1, 2026

Summary

Cleaned check_rate_limit.cjs (github-script context) as part of the jsweep JavaScript unbloat initiative.

Changes

check_rate_limit.cjs

  • Import getErrorMessage from error_helpers.cjs and use it throughout, replacing 3 instances of inline error instanceof Error ? error.message : String(error) pattern
  • Added type annotation /** @type {Record(string, number)} */ for runsPerEvent variable to improve type safety

check_rate_limit.test.cjs

  • Fixed test pollution: Added delete process.env.GITHUB_WORKFLOW_REF to beforeEach cleanup (was missing, could cause test interference)
  • Added 5 new test cases:
    1. issue_comment events are rate-limited by default (programmatic event)
    2. discussion_comment events are rate-limited by default (programmatic event)
    3. pull_request events are NOT rate-limited by default (non-programmatic)
    4. Stack trace is logged when error has one
    5. (cleanup fix test coverage)

Context

  • Execution context: github-script
  • Tests before: 24 test cases
  • Tests after: 29 test cases (+5)

Validation ✅

  • Formatting: npm run format:cjs
  • Linting: npm run lint:cjs
  • Type checking: npm run typecheck
  • Tests: All 29 check_rate_limit tests pass ✓ (pre-existing unrelated failures in assign_issue, mcp_handler_go, frontmatter_hash_github_api, safe_outputs_tools_loader are not caused by these changes)

Generated by jsweep - JavaScript Unbloater

Warning

⚠️ Firewall blocked 1 domain

The following domain was blocked by the firewall during workflow execution:

  • proxy.golang.org

To allow these domains, add them to the network.allowed list in your workflow frontmatter:

network:
  allowed:
    - defaults
    - "proxy.golang.org"

See Network Configuration for more information.

  • expires on Mar 3, 2026, 3:25 AM UTC

- Import and use getErrorMessage() from error_helpers.cjs instead of
  inline error instanceof Error checks (3 occurrences removed)
- Add `/** @type {Record<string, number>} */` annotation for runsPerEvent
- Fix GITHUB_WORKFLOW_REF env var not being cleaned up in test beforeEach
- Add 5 new test cases: issue_comment/discussion_comment/pull_request
  event handling, stack trace logging, env var cleanup verification

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@pelikhan pelikhan marked this pull request as ready for review March 1, 2026 03:38
Copilot AI review requested due to automatic review settings March 1, 2026 03:38
@pelikhan pelikhan merged commit 2306ae7 into main Mar 1, 2026
47 checks passed
@pelikhan pelikhan deleted the jsweep/clean-check-rate-limit-ced84f749153f701 branch March 1, 2026 03:39
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Cleans up check_rate_limit.cjs error handling by standardizing error-message extraction, and improves the check_rate_limit test suite by fixing an environment-variable pollution issue and adding coverage for default event behavior and stack-trace logging.

Changes:

  • Use shared getErrorMessage helper in check_rate_limit.cjs and add a JSDoc type for runsPerEvent.
  • Fix test isolation by clearing GITHUB_WORKFLOW_REF in beforeEach.
  • Add tests for default programmatic vs non-programmatic events and for stack trace logging on errors.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
actions/setup/js/check_rate_limit.cjs Replaces inline error-to-message logic with getErrorMessage and adds typing for runsPerEvent.
actions/setup/js/check_rate_limit.test.cjs Prevents env var leakage across tests and adds new cases covering default event behavior + stack trace logging.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants