[jsweep] Clean assign_agent_helpers.cjs#19495
Closed
github-actions[bot] wants to merge 4 commits intomainfrom
Closed
[jsweep] Clean assign_agent_helpers.cjs#19495github-actions[bot] wants to merge 4 commits intomainfrom
github-actions[bot] wants to merge 4 commits intomainfrom
Conversation
- 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>
Contributor
|
@copilot lint js |
Contributor
Contributor
There was a problem hiding this comment.
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()viagetErrorMessage(). - Added new unit tests covering
getPullRequestDetails,logPermissionError, andlogGraphQLErrorDetails.
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.cjsExtracted
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 tocore.info, one for generic errors logging tocore.error) are now replaced by a single reusable helper:This removes ~35 lines of duplicated code and makes the error handling logic clear and testable.
Used
getErrorMessage()consistently —getAvailableAgentLoginswas using an inlinee instanceof Error ? e.message : String(e)pattern instead of the sharedgetErrorMessage()helper already imported at the top.assign_agent_helpers.test.cjsAdded 20 new tests covering previously untested exports:
getPullRequestDetails(5 tests): success path, not-found, GraphQL errors, empty assignees, null idlogPermissionError(3 tests): permission messages, settings guidance, docs linklogGraphQLErrorDetails(5 tests): error details logged line-by-line, null error, empty object, compactMessages extraction, non-object errorsTotal: 48 tests (up from 28)
Validation
npm run format:cjs✓npm run lint:cjs✓npm run typecheck✓npx vitest run assign_agent_helpers) ✓Warning
The following domain was blocked by the firewall during workflow execution:
proxy.golang.orgTo allow these domains, add them to the
network.allowedlist in your workflow frontmatter:See Network Configuration for more information.