Fix: close_issue and add_labels handlers ignore target-repo config#15031
Merged
Fix: close_issue and add_labels handlers ignore target-repo config#15031
close_issue and add_labels handlers ignore target-repo config#15031Conversation
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Fix safe output handlers for cross-repository operations
Fix: Feb 11, 2026
close_issue and add_labels handlers ignore target-repo config
Contributor
There was a problem hiding this comment.
Pull request overview
Fixes cross-repository safe-output behavior by making the close_issue and add_labels handlers honor the compiled target-repo / allowed_repos configuration (via the existing repo_helpers.cjs resolution/validation pattern already used by add_comment).
Changes:
- Update
close_issue.cjsandadd_labels.cjsto resolve/validate the target repository per message usingresolveTargetRepoConfig+resolveAndValidateRepo, and to issue API calls against the resolvedowner/repoinstead ofcontext.repo. - Add comprehensive new unit tests for
close_issue(new test file) and extendadd_labelstests to cover cross-repo behavior (config default target-repo, messagerepooverride, allowed-repos enforcement, bare repo qualification).
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| actions/setup/js/close_issue.cjs | Uses repo_helpers.cjs to honor target-repo / allowed_repos and routes REST calls to resolved owner/repo. |
| actions/setup/js/add_labels.cjs | Same repo resolution/validation; replaces ...context.repo with resolved owner/repo for label operations and logging. |
| actions/setup/js/close_issue.test.cjs | Adds a full test suite including cross-repo scenarios and allowed-repos enforcement. |
| actions/setup/js/add_labels.test.cjs | Adds targeted tests validating the new cross-repo behavior and validation rules. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
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.
close_issue.cjsandadd_labels.cjswere hardcoded tocontext.repo, preventing cross-repository operations despitetarget-repobeing correctly compiled intoGH_AW_SAFE_OUTPUTS_HANDLER_CONFIG.Changes
Adopt
repo_helpers.cjspattern (already used inadd_comment.cjs):resolveTargetRepoConfigandresolveAndValidateRepodefaultTargetRepoandallowedReposfrom config at handler initializationclose_issue:context.repo.owner/repo→repoParts.owner/repoadd_labels:...context.repo→owner: repoParts.owner, repo: repoParts.repoTest coverage:
close_issue.cjs(new file)add_labels.cjsExample
Previously: handlers ignored config, operated only on workflow's repository
Now: handlers resolve target repo from config or message's
repofieldOriginal prompt
close_issueandadd_labelssafe output handlers do not support target-repo for cross-repository operations #15027✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.