fix: add pull-requests:write to safe_outputs job for add-comment#18318
fix: add pull-requests:write to safe_outputs job for add-comment#18318
Conversation
…configured - Add Issues and PullRequests fields to AddCommentsConfig struct - Default: issues=true (issues:write), pull-requests=true (pull-requests:write), discussions=false (no discussions:write) - Update buildCreateOutputAddCommentJob to use dynamic permissions and conditions - Add buildAddCommentPermissions helper shared by job builder and permissions calculator - Update ComputePermissionsForSafeOutputs to use the new helper - Update JSON schema with issues and pull-requests boolean properties - Update tests to reflect new default behavior - Recompile all workflow lock files Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
|
@copilot enable discussion: true by default |
Change discussions default from false back to true (nil = true). Now all three target types default to true: - issues: nil or true → issues:write - pull-requests: nil or true → pull-requests:write - discussions: nil or true → discussions:write Set any field to false to opt out of that permission/event condition. Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Done in 38ab344. Warning Firewall rules blocked me from connecting to one or more addresses (expand for details)I tried to connect to the following addresses, but was blocked by firewall rules:
If you need me to access, download, or install something from one of these locations, you can either:
|
There was a problem hiding this comment.
Pull request overview
This pull request fixes a bug where the compiler only emitted issues: write permission for safe_outputs jobs with add-comment configured, causing "Resource not accessible by integration" errors when posting comments on pull requests.
Changes:
- Added configurable
issues,pull-requests, anddiscussionsfields to theadd-commentconfiguration (all default totrue) - Created shared
buildAddCommentPermissions()helper function used by both the dedicated job builder andComputePermissionsForSafeOutputs - Implemented dynamic event condition building that reflects which target types are enabled
Reviewed changes
Copilot reviewed 21 out of 21 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| pkg/workflow/add_comment.go | Added new configurable fields (Issues, PullRequests, Discussions), created buildAddCommentPermissions() helper, and updated event condition building logic to be dynamic based on enabled target types |
| pkg/workflow/safe_outputs_permissions.go | Refactored to use the new shared buildAddCommentPermissions() helper instead of inline permission logic |
| pkg/workflow/safe_outputs_permissions_test.go | Added comprehensive test coverage for all permission combinations (default, discussions:true/false, pull-requests:false, issues:false) |
| pkg/parser/schemas/main_workflow_schema.json | Added schema definitions for the three new boolean fields with proper descriptions |
| .github/workflows/*.lock.yml | All 158 workflow lock files recompiled to include pull-requests: write permission in safe_outputs jobs |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Smoke Test: Gemini Engine Validation
Overall Status: FAIL
|
add-commentcan target both issues and pull requests, but the compiler only emittedissues: write— causing "Resource not accessible by integration" when posting comments on PRs.Changes
issuesandpull-requestsfields onadd-comment— control permission emission and event condition targeting. Both default totrue.discussionsremainstrueby default — setdiscussions: falseto opt out if your GitHub App lacks Discussions permission.github.event.issue.number || github.event.pull_request.number || github.event.discussion.number).buildAddCommentPermissions()helper — used by both the dedicated add_comment job builder andComputePermissionsForSafeOutputs.Generated
safe_outputspermissions now includepull-requests: writeby default:All 158 workflow lock files recompiled — updated to include
pull-requests: writealongsideissues: writeanddiscussions: write.Original prompt
🔒 GitHub Advanced Security automatically protects Copilot coding agent pull requests. You can protect all pull requests by enabling Advanced Security for your repositories. Learn more about Advanced Security.