-
Notifications
You must be signed in to change notification settings - Fork 251
Description
π€ Filed by AI
Problem
The compiled .lock.yml conclusion job always requests discussions: write permission β both in the job's permissions: block and via permission-discussions: write on the GitHub App token step β even when the workflow has no discussion-related safe-outputs configured (e.g., no create-discussion, close-discussion, update-discussion).
This causes a 422 error when the GitHub App installation doesn't have the Discussions permission granted:
RequestError [HttpError]: The permissions requested are not granted to this installation.
Additionally, permission-discussions is flagged as an unexpected input by actions/create-github-app-token@v2.2.1:
##[warning]Unexpected input(s) 'permission-discussions', valid inputs are [...]
Reproduction
- Create a workflow with only issue/label-related safe-outputs (no discussions):
---
on:
workflow_dispatch:
permissions:
contents: read
issues: read
tools:
github:
toolsets: [issues]
read-only: true
app:
app-id: ${{ secrets.APP_ID }}
private-key: ${{ secrets.APP_PRIVATE_KEY }}
owner: 'myorg'
repositories: ['myrepo']
safe-outputs:
app:
app-id: ${{ secrets.APP_ID }}
private-key: ${{ secrets.APP_PRIVATE_KEY }}
owner: 'myorg'
repositories: ['myrepo']
add-labels:
max: 5
remove-labels:
allowed: ["triage-needed"]
max: 2
assign-to-user:
max: 1
---
# My Workflow
Do something with issues only.- Compile:
gh aw compile - Observe the generated conclusion job in
.lock.yml:
conclusion:
permissions:
contents: read
discussions: write # <-- not needed
issues: write
pull-requests: write
steps:
- name: Generate GitHub App token
uses: actions/create-github-app-token@...
with:
permission-discussions: write # <-- not needed, also not a valid input- Run the workflow β the conclusion job fails at the token step if the GitHub App doesn't have Discussions permission.
Expected Behavior
The conclusion job should only request permissions that are actually needed based on the workflow's configured safe-outputs. If no discussion-related safe-outputs are configured, discussions: write should not be included in either the job permissions or the app token request.
Actual Behavior
discussions: write is unconditionally added to every conclusion job regardless of whether any discussion-related safe-outputs are configured.
Environment
- gh-aw version: v0.43.9 and v0.43.21 (both affected)
- actions/create-github-app-token: v2.2.1
Additional Context
- Failed run: https://github.com/microsoft/vscode-engineering/actions/runs/22003392790/job/63581823271
- The same principle of least privilege should ideally apply to
pull-requests: writeβ if the workflow only uses issue-related safe-outputs,pull-requests: writeshouldn't be requested either.