Skip to content

push-to-pull-request-branch makes the GitHub App token request administration: read; the mint fails and failure reporting then crashes #73075

Done

Description

@kdowswell

Summary

With safe-outputs.github-app and push-to-pull-request-branch, the compiler adds permission-administration: read to the App token request for the branch-protection pre-flight. Agent Apps are usually installed without Administration, so actions/create-github-app-token fails: "The permissions requested are not granted to this installation". Nothing is pushed. The conclusion job then fails too: Unhandled error: Error: Input required and not supplied: github-token in "Handle agent failure" and "Report failed jobs", so the run never reports why.

The pre-flight doesn't actually need the permission. With a GITHUB_TOKEN-style 403 it already warns and continues, because GitHub enforces branch protection at push time anyway. Only the App token mint makes it fatal.

Root cause

  • pkg/workflow/safe_output_handlers.go:513-515: if getCheckBranchProtection(...) { permissions.Set(PermissionAdministration, PermissionRead) }.
  • actions/setup/js/pr_helpers.cjs:143-171 uses repos.getBranchProtection, which needs Administration. It already treats a 403 as "warn and proceed" (lines 155-159).
  • pkg/workflow/github_token.go:188-199 gives conclusion steps a fallback token only for ignore-if-missing or an unminted global token, not when minting fails at runtime. app_token_minting_failed is computed (compiler_safe_outputs_job.go:868, notify_comment_conclusion_helpers.go:386), but github-token is empty, so actions/github-script errors before the script runs.

Implementation plan

  1. In actions/setup/js/pr_helpers.cjs, check protection with repos.getBranch (protected boolean, needs only contents: read) instead of getBranchProtection. Keep the existing 404/403/error semantics.
  2. In pkg/workflow/safe_output_handlers.go, stop adding PermissionAdministration for check-branch-protection.
  3. In pkg/workflow/github_token.go, give conclusion and failure-report steps combineTokenExpressions(app token, github.token), so a failed mint can still be reported.
  4. Tests:
    • pkg/workflow/app_token_permissions_validation_test.go: no administration in the push handler's App token permissions;
    • pr_helpers.test.cjs: protected: true blocks, false proceeds;
    • a compiler test: conclusion steps have a fallback token with github-app.
  5. Docs, reference/safe-outputs-pull-requests.md:564: it says a token without administration: read "logs a warning and continues". That's true for GITHUB_TOKEN but not for github-app, where the mint itself fails. Update the paragraph to match the new behaviour.

Acceptance criteria

A workflow using github-app and push-to-pull-request-branch mints its token with an App that has no Administration permission. If any App token mint fails, the conclusion job still reports it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions