The add-labels safe-output unconditionally requires pull-requests: write in the minted GitHub App token, even when every target is an issue. Unlike add-comment, it exposes no toggle to exclude the PR scope. An App intentionally scoped to contents: read + issues: write therefore cannot use add-labels — the token mint fails with The permissions requested are not granted to this installation (HTTP 422).
Scenario
- A GitHub App granted only
contents: read + issues: write.
- Goal: read existing issues, add comments to them, and apply a label to the issue. No pull-request access wanted or granted.
add-comment works within these scopes by setting pull-requests: false.
add-labels has no equivalent, so the safe_outputs job's token mint is rejected and no comment/label is written.
Reproduction
safe-outputs:
github-app:
client-id: ${{ vars.APP_CLIENT_ID }}
private-key: ${{ secrets.APP_PRIVATE_KEY }}
owner: my-org
repositories: [my-repo]
add-comment:
pull-requests: false # OK: excludes pull-requests:write
add-labels:
allowed: [routed] # always forces pull-requests:write
Compile and run against an App that lacks pull-requests: write. The safe_outputs job fails at Generate GitHub App token:
The permissions requested are not granted to this installation. (HTTP 422)
Expected behavior
add-labels should be usable with issues: write alone when it targets only issues — mirroring the issues: / pull-requests: handler toggles that add-comment already supports, or inferring issue-only scope from the resolved target so the minted token omits pull-requests: write when PRs aren't targeted.
Actual behavior
add-labels always requests contents: read + issues: write + pull-requests: write, with no opt-out.
Source pointers and a minimal fix that mirrors add-comment
add-comment's toggle lives in pkg/workflow/add_comment.go: AddCommentsConfig.PullRequests *bool (yaml pull-requests), and buildAddCommentPermissions() adds pull-requests: write only when that field is nil/true.
add-labels lives in pkg/workflow/add_labels.go: AddLabelsConfig has no Issues / PullRequests fields.
- Its permission builder is the
add-labels descriptor in pkg/workflow/safe_output_handlers.go, which returns the hardcoded NewPermissionsContentsReadIssuesWritePRWrite().
- Minimal change: add
Issues / PullRequests *bool to AddLabelsConfig, add a buildAddLabelsPermissions() that mirrors buildAddCommentPermissions(), and point the add-labels descriptor's PermissionBuilder at it instead of the fixed constant.
- Docs follow-up: the safe-outputs reference doesn't cover the
pull-requests: / issues: toggles for add-comment (the pull-requests: false behavior is currently only discoverable in source); document them for both handlers.
Related
Environment
- gh-aw compiler: behavior verified in current
main source (see details above); reproduced on the v0.83.x setup action.
actions/create-github-app-token@v3.2.0.
The
add-labelssafe-output unconditionally requirespull-requests: writein the minted GitHub App token, even when every target is an issue. Unlikeadd-comment, it exposes no toggle to exclude the PR scope. An App intentionally scoped tocontents: read+issues: writetherefore cannot useadd-labels— the token mint fails withThe permissions requested are not granted to this installation(HTTP 422).Scenario
contents: read+issues: write.add-commentworks within these scopes by settingpull-requests: false.add-labelshas no equivalent, so thesafe_outputsjob's token mint is rejected and no comment/label is written.Reproduction
Compile and run against an App that lacks
pull-requests: write. Thesafe_outputsjob fails at Generate GitHub App token:Expected behavior
add-labelsshould be usable withissues: writealone when it targets only issues — mirroring theissues:/pull-requests:handler toggles thatadd-commentalready supports, or inferring issue-only scope from the resolvedtargetso the minted token omitspull-requests: writewhen PRs aren't targeted.Actual behavior
add-labelsalways requestscontents: read+issues: write+pull-requests: write, with no opt-out.Source pointers and a minimal fix that mirrors
add-commentadd-comment's toggle lives inpkg/workflow/add_comment.go:AddCommentsConfig.PullRequests *bool(yamlpull-requests), andbuildAddCommentPermissions()addspull-requests: writeonly when that field is nil/true.add-labelslives inpkg/workflow/add_labels.go:AddLabelsConfighas noIssues/PullRequestsfields.add-labelsdescriptor inpkg/workflow/safe_output_handlers.go, which returns the hardcodedNewPermissionsContentsReadIssuesWritePRWrite().Issues/PullRequests *booltoAddLabelsConfig, add abuildAddLabelsPermissions()that mirrorsbuildAddCommentPermissions(), and point theadd-labelsdescriptor'sPermissionBuilderat it instead of the fixed constant.pull-requests:/issues:toggles foradd-comment(thepull-requests: falsebehavior is currently only discoverable in source); document them for both handlers.Related
issues:*cap but notadd-labels' PR scope.Environment
mainsource (see details above); reproduced on thev0.83.xsetup action.actions/create-github-app-token@v3.2.0.