fix: safe output handlers now respect target-repo config#35901
Merged
Conversation
Several safe output JS handlers were hardcoding context.repo.owner/repo instead of reading from the target-repo config field. This caused cross-repository routing to be silently ignored when operators configured a target-repo constraint. Fixed handlers: - close_pull_request.cjs - mark_pull_request_as_ready_for_review.cjs - close_discussion.cjs - link_sub_issue.cjs - assign_milestone.cjs Each handler now calls resolveTargetRepoConfig(config) to read the target-repo and allowed_repos config fields, and resolveAndValidateRepo to validate individual message targets against them. Also updated tool_description_enhancer.go to emit TargetRepoSlug constraints in tool descriptions shown to AI agents for all five handlers, ensuring agents are aware of the configured repository restriction. Added JS tests for all fixed handlers and Go tests for the tool description enhancer changes.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
Contributor
There was a problem hiding this comment.
Pull request overview
Fixes safe-output JS handlers that previously hardcoded context.repo so they now honor the target-repo (and where applicable allowed_repos) handler configuration, and surfaces the configured target repo in the tool descriptions shown to the agent.
Changes:
- Five JS handlers (
close_pull_request,mark_pull_request_as_ready_for_review,close_discussion,link_sub_issue,assign_milestone) now resolve the target repo from config viaresolveTargetRepoConfig/resolveAndValidateRepoand use the resolved owner/repo for all GitHub API calls. tool_description_enhancer.goappendsTargetRepoSlugconstraint text for those five tools (and adds a max-count line formark_pull_request_as_ready_for_review).- New JS handler tests for target-repo routing and Go tests for the description enhancer; unrelated formatting compaction in
awf-config.schema.json.
Show a summary per file
| File | Description |
|---|---|
| actions/setup/js/close_pull_request.cjs | Resolve+validate per-item repo in resolveTarget and propagate owner/repo. |
| actions/setup/js/mark_pull_request_as_ready_for_review.cjs | Resolve per-item repo and use it for filter, PR details, and comment calls. |
| actions/setup/js/close_discussion.cjs | Manually parse defaultTargetRepo and use it for discussion lookup. |
| actions/setup/js/link_sub_issue.cjs | Manually parse defaultTargetRepo and use it for issue resolution defaults. |
| actions/setup/js/assign_milestone.cjs | Plumb resolved repo into milestone find/create/get/update calls; thread owner/repo through findMilestoneByTitle. |
| actions/setup/js/*.test.cjs (4 files) | Add target-repo routing, fallback, allowed-repos, and rejection tests. |
| pkg/workflow/tool_description_enhancer.go | Emit target-repo constraint strings and a max-count line for the five handlers. |
| pkg/workflow/tool_description_enhancer_test.go | Verify the new constraints appear in tool descriptions. |
| pkg/workflow/schemas/awf-config.schema.json | Pure formatting: collapse short enum/required arrays to one line. |
Copilot's findings
Tip
Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
- Files reviewed: 12/12 changed files
- Comments generated: 4
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
This comment has been minimized.
This comment has been minimized.
…ndValidateRepo - Use allowedRepos.size (not .length) and Array.from(allowedRepos).join(...) in mark_pull_request_as_ready_for_review.cjs and assign_milestone.cjs (allowedRepos is a Set<string> returned by resolveTargetRepoConfig) - Add per-item resolveAndValidateRepo call to close_discussion.cjs so that item.repo overrides and allowed_repos validation apply per message - Add per-item resolveAndValidateRepo call to link_sub_issue.cjs and pass the resolved owner/repo to resolveRepoIssueTarget for both parent and sub-issue; ignored allowed_repos now validated - Add JS tests covering allowed_repos rejection and item.repo override for close_discussion and link_sub_issue
This comment has been minimized.
This comment has been minimized.
Contributor
|
|
This comment has been minimized.
This comment has been minimized.
…real network calls
This comment has been minimized.
This comment has been minimized.
… logs order tests TestLogsJSONOutputBeforeStderr and TestLogsJSONAndStderrRedirected were failing when gh CLI is available but the test workflow name doesn't exist, returning 'failed to list workflow runs (exit code 1)' which wasn't in the skip condition list. Added this error string to both skip checks.
Contributor
|
✅ smoke-ci: safeoutputs CLI comment + comment-memory run (26683528903)
|
github-actions Bot
added a commit
that referenced
this pull request
May 30, 2026
* fix: safe output handlers now respect target-repo config Several safe output JS handlers were hardcoding context.repo.owner/repo instead of reading from the target-repo config field. This caused cross-repository routing to be silently ignored when operators configured a target-repo constraint. Fixed handlers: - close_pull_request.cjs - mark_pull_request_as_ready_for_review.cjs - close_discussion.cjs - link_sub_issue.cjs - assign_milestone.cjs Each handler now calls resolveTargetRepoConfig(config) to read the target-repo and allowed_repos config fields, and resolveAndValidateRepo to validate individual message targets against them. Also updated tool_description_enhancer.go to emit TargetRepoSlug constraints in tool descriptions shown to AI agents for all five handlers, ensuring agents are aware of the configured repository restriction. Added JS tests for all fixed handlers and Go tests for the tool description enhancer changes. * Potential fix for pull request finding Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com> * Potential fix for pull request finding Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com> * fix: address PR review comments - Set API usage and per-item resolveAndValidateRepo - Use allowedRepos.size (not .length) and Array.from(allowedRepos).join(...) in mark_pull_request_as_ready_for_review.cjs and assign_milestone.cjs (allowedRepos is a Set<string> returned by resolveTargetRepoConfig) - Add per-item resolveAndValidateRepo call to close_discussion.cjs so that item.repo overrides and allowed_repos validation apply per message - Add per-item resolveAndValidateRepo call to link_sub_issue.cjs and pass the resolved owner/repo to resolveRepoIssueTarget for both parent and sub-issue; ignored allowed_repos now validated - Add JS tests covering allowed_repos rejection and item.repo override for close_discussion and link_sub_issue * fix: resolve CGO CI failures - mutex defer, init skill dir, test mock * fix: add missing mocks in TestUpdateManifestWorkflowGroup to prevent real network calls * fix: add missing skip condition for 'failed to list workflow runs' in logs order tests TestLogsJSONOutputBeforeStderr and TestLogsJSONAndStderrRedirected were failing when gh CLI is available but the test workflow name doesn't exist, returning 'failed to list workflow runs (exit code 1)' which wasn't in the skip condition list. Added this error string to both skip checks. --------- Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
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.
Cross-repo support for safe-output handlers + bug fixes
Summary
This PR delivers two main themes:
Cross-repo support for safe-output action handlers — five JS action handlers (
assign_milestone,close_discussion,link_sub_issue,mark_pull_request_as_ready_for_review, andclose_pull_request) now resolve their target repository viaresolveTargetRepoConfig/resolveAndValidateRepofromrepo_helpers.cjsinstead of blindly readingcontext.repo. The Go-sidetool_description_enhancerwas updated in parallel to injectTargetRepoSlugconstraints and max-count descriptions for these tools.Reliability / CI bug fixes — a mutex defer correctness fix in
remote_fetch.go, a missing directory guard incopilot_agents.go, two test isolation fixes (missing mocks, missing skip condition), and a pull-request-finding fix.Changed files
Actions — cross-repo handler updates (
actions/setup/js/)assign_milestone.cjsresolveTargetRepoConfig+resolveAndValidateRepofor cross-repo milestone assignmentassign_milestone.test.cjstarget-repo supportsuite: default fallback, explicit config, allowed list, rejectionclose_discussion.cjslink_sub_issue.cjscontext.repowith configurable repo resolutionlink_sub_issue.test.cjsallowed_reposrejectionmark_pull_request_as_ready_for_review.cjscontext.repoowner/repo references replaced with resolved valuesmark_pull_request_as_ready_for_review.test.cjsGo — tool description enhancer (
pkg/workflow/)tool_description_enhancer.goTargetRepoSlugconstraints + max-count formark_pull_request_as_ready_for_review,close_discussion,close_pr,link_sub_issue,assign_milestonetool_description_enhancer_test.goschemas/awf-config.schema.jsonGo — bug fixes (
pkg/)pkg/parser/remote_fetch.gogetOrCreateListRepoClone; eliminates manual unlock riskpkg/cli/copilot_agents.goos.IsNotExistguard for absent.github/awdirectory; returns safe default instead of propagating errorpkg/cli/logs_json_stderr_order_test.go"failed to list workflow runs"to prevent false CI failurespkg/cli/update_manifest_test.golistPackageDirSubdirsForHost/listPackageDirFilesForHostto block real network callspkg/cli/add_package_manifest_test.goskills/my-skill/SKILL.mdstub to cover skill manifest pathImpact
target-repoconfig will now correctly fan out actions to the configured repo instead of always operating on the triggering repo.Testing
target-repo supporttest suites added for all three modified JS handlers.tool_description_enhancer_test.gocovers all new constraint cases.