Skip to content

[jsweep] Clean assign_agent_helpers.cjs#19495

Closed
github-actions[bot] wants to merge 4 commits intomainfrom
jsweep/clean-assign-agent-helpers-653b7c6142a9f284
Closed

[jsweep] Clean assign_agent_helpers.cjs#19495
github-actions[bot] wants to merge 4 commits intomainfrom
jsweep/clean-assign-agent-helpers-653b7c6142a9f284

Conversation

@github-actions
Copy link
Contributor

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

Summary

Cleaned actions/setup/js/assign_agent_helpers.cjs — a github-script context file providing shared GraphQL helpers for assigning coding agents (like Copilot) to issues and pull requests.

Changes

assign_agent_helpers.cjs

Extracted logGraphQLErrorDetails() helper — eliminated two nearly-identical nested try/catch blocks that serialized GraphQL error objects and logged them line-by-line. The two blocks (one for 502 errors logging to core.info, one for generic errors logging to core.error) are now replaced by a single reusable helper:

function logGraphQLErrorDetails(error, header, logFn) { ... }

This removes ~35 lines of duplicated code and makes the error handling logic clear and testable.

Used getErrorMessage() consistentlygetAvailableAgentLogins was using an inline e instanceof Error ? e.message : String(e) pattern instead of the shared getErrorMessage() helper already imported at the top.

assign_agent_helpers.test.cjs

Added 20 new tests covering previously untested exports:

  • getPullRequestDetails (5 tests): success path, not-found, GraphQL errors, empty assignees, null id
  • logPermissionError (3 tests): permission messages, settings guidance, docs link
  • logGraphQLErrorDetails (5 tests): error details logged line-by-line, null error, empty object, compactMessages extraction, non-object errors

Total: 48 tests (up from 28)

Validation

  • ✅ Formatting: npm run format:cjs
  • ✅ Linting: npm run lint:cjs
  • ✅ Type checking: npm run typecheck
  • ✅ Tests: 48/48 pass (npx vitest run assign_agent_helpers) ✓

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 6, 2026, 3:18 AM UTC

- Use getErrorMessage() consistently in getAvailableAgentLogins
- Extract logGraphQLErrorDetails() helper to eliminate duplicated
  error serialization/logging logic in assignAgentToIssue
- Add tests for getPullRequestDetails, logPermissionError, and
  logGraphQLErrorDetails (48 tests total, up from 28)

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@pelikhan pelikhan marked this pull request as ready for review March 4, 2026 03:35
Copilot AI review requested due to automatic review settings March 4, 2026 03:35
@pelikhan
Copy link
Contributor

pelikhan commented Mar 4, 2026

@copilot lint js

Copy link
Contributor

Copilot AI commented Mar 4, 2026

@pelikhan I've opened a new pull request, #19501, to work on those changes. Once the pull request is ready, I'll request review from you.

Copy link
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

Refactors shared GitHub Actions github-script GraphQL helpers to reduce duplicated error-logging code and expands unit test coverage for previously untested exports.

Changes:

  • Extracted a reusable logGraphQLErrorDetails() helper and replaced duplicated nested logging blocks.
  • Standardized error message formatting in getAvailableAgentLogins() via getErrorMessage().
  • Added new unit tests covering getPullRequestDetails, logPermissionError, and logGraphQLErrorDetails.

Reviewed changes

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

File Description
actions/setup/js/assign_agent_helpers.cjs Deduplicates GraphQL error logging via logGraphQLErrorDetails and uses getErrorMessage consistently.
actions/setup/js/assign_agent_helpers.test.cjs Adds targeted tests for PR details retrieval and new/expanded logging helpers.

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

You can also share your feedback on Copilot code review. Take the survey.

@pelikhan pelikhan closed this Mar 4, 2026
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.

3 participants