Skip to content

fix: restore permission-discussions in GitHub App token fields#25709

Merged
pelikhan merged 1 commit intomainfrom
fix-restore-permission-discussions
Apr 10, 2026
Merged

fix: restore permission-discussions in GitHub App token fields#25709
pelikhan merged 1 commit intomainfrom
fix-restore-permission-discussions

Conversation

@lpcox
Copy link
Copy Markdown
Collaborator

@lpcox lpcox commented Apr 10, 2026

Summary

Reverts the regression introduced by PR #25508, which removed permission-discussions from the convertPermissionsToAppTokenFields() function.

Root Cause

PR #25508 was based on two incorrect assumptions about actions/create-github-app-token:

1. "Unsupported inputs are silently ignored"

Wrong. The action reads all INPUT_PERMISSION-* environment variables from process.env, not just declared inputs (source):

GitHub Actions sets INPUT_PERMISSION-DISCUSSIONS for any with: permission-discussions: field, so the value IS forwarded to the GitHub API despite the "Unexpected input" warning in the logs.

2. "Tokens inherit full installation permissions by default"

Only partially true. This is only the case when zero permission-* inputs are specified. When any permission-* field is set (which the compiler always does — permission-contents, permission-issues, etc.), the token is explicitly scoped to only those permissions:

// Returns undefined (inherit all) only when no permissions found
}, undefined);

Omitting permission-discussions causes the minted token to lack discussions access even when the GitHub App installation has that permission.

Impact

  • create-discussion safe-outputs fail with permissions errors
  • Falls back to issue creation (if fallback-to-issue: true)
  • Affects all workflows using GitHub App auth with discussion safe-outputs

Changes

  • safe_outputs_app_config.go: Restore permission-discussions mapping with corrected comment explaining the actual behavior
  • safe_outputs_app_test.go: Update test to assert permission-discussions: write IS present
  • github_app_permissions_validation_test.go: Update test to verify discussions permission IS mapped

Testing

  • All modified tests pass (TestSafeOutputsAppTokenDiscussionsPermission, TestConvertPermissionsToAppTokenFields_GitHubAppOnly)
  • Pre-existing test failures unrelated to this change

Closes #25704

PR #25508 removed permission-discussions from convertPermissionsToAppTokenFields()
based on two incorrect assumptions:

1. That unsupported inputs are silently ignored by actions/create-github-app-token.
   In reality, the action reads ALL INPUT_PERMISSION-* env vars from process.env
   (see lib/get-permissions-from-inputs.js), not just declared inputs.

2. That GitHub App tokens inherit full installation permissions by default.
   This is only true when ZERO permission-* inputs are set. When any permission-*
   field is specified (which the compiler always does), the token is scoped to
   only those permissions — omitting permission-discussions excludes discussions.

This caused create-discussion safe-outputs to fail with permissions errors and
fall back to issue creation when using GitHub App authentication.

Closes #25704

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings April 10, 2026 21:29
@pelikhan
Copy link
Copy Markdown
Collaborator

@lpcox the actions/create... needs to fix the warning

@pelikhan
Copy link
Copy Markdown
Collaborator

@salmanmkc

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Restores permission-discussions generation for GitHub App token minting so safe-outputs that create discussions request the correct scoped permissions again (regression from PR #25508).

Changes:

  • Re-add PermissionDiscussionspermission-discussions mapping in convertPermissionsToAppTokenFields(), with updated rationale comment.
  • Update safe-outputs workflow compilation test to assert permission-discussions: write is emitted for create-discussion.
  • Update GitHub App permissions mapping validation test to expect permission-discussions to be present.
Show a summary per file
File Description
pkg/workflow/safe_outputs_app_config.go Restores discussions permission mapping for GitHub App token with: permission-* fields.
pkg/workflow/safe_outputs_app_test.go Updates test expectations to require permission-discussions: write in the minted-token step.
pkg/workflow/github_app_permissions_validation_test.go Updates mapping validation test to expect permission-discussions output.

Copilot's findings

Tip

Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

  • Files reviewed: 3/3 changed files
  • Comments generated: 0

@pelikhan pelikhan merged commit a4b7f5b into main Apr 10, 2026
96 checks passed
@pelikhan pelikhan deleted the fix-restore-permission-discussions branch April 10, 2026 21:48
@salmanmkc
Copy link
Copy Markdown
Collaborator

salmanmkc commented Apr 10, 2026

@salmanmkc

this should fix it
actions/create-github-app-token#359
actions/create-github-app-token#360

some override seems like was a snapshot and is now outdated, updated this too, this is upstream and if this was right then the above pr wouldn't be needed either octokit/openapi#529

this also seems to fix it http://github.com/actions/create-github-app-token/pull/358l

@ahamedjobayer081-spec
Copy link
Copy Markdown

  1. 1

@github-actions github-actions bot added the spam label Apr 10, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

v0.68.1: create_discussion safe-output fails — compiler omits discussions permission from app token

5 participants