Skip to content

Remove Administration requirement from PR branch pushes and preserve failure reporting - #74946

Merged
pelikhan merged 6 commits into
mainfrom
copilot/fix-token-request-permission-issue
Nov 5, 2026
Merged

pelikhan merged 6 commits into
mainfrom
copilot/fix-token-request-permission-issue

Conversation

Copilot AI commented Nov 4, 2026 •

Copy link
Copy Markdown
Contributor

PR branch pushes requested administration: read, causing token minting to fail for Apps without that permission. Failure reporting then crashed because it received an empty token.

  • Least-privilege branch checks: Use repos.getBranch().protected instead of getBranchProtection; remove the Administration request while preserving existing error handling.
  • Resilient failure reporting: Give “Handle agent failure” and “Report failed jobs” an App-token fallback:
    github-token: ${{ steps.safe-outputs-app-token.outputs.token || github.token }}
    Normal push authentication remains unchanged.
  • Coverage and documentation: Add regression coverage for protection flags, App permission scopes, and reporting fallback; update the permission requirements.

Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix token request permission issue for GitHub App Remove Administration requirement from PR branch pushes and preserve failure reporting Nov 4, 2026
Copilot AI requested a review from pelikhan November 4, 2026 19:47
@pelikhan
pelikhan marked this pull request as ready for review November 4, 2026 20:07
Copilot AI adaptive review requested due to automatic review settings November 4, 2026 20:07
@github-actions

github-actions Bot commented Nov 4, 2026 •

Copy link
Copy Markdown
Contributor

✅ PR Code Quality Reviewer completed the code quality review.

🔎 Code quality review by PR Code Quality Reviewer

@github-actions

github-actions Bot commented Nov 4, 2026 •

Copy link
Copy Markdown
Contributor

✅ Design Decision Gate 🏗️ completed the design decision gate check. See the comment below for the result and any generated ADR draft.

Design Decision Gate 🏗️

Outcome: reported_no_action

The agent completed and reported no action. A no-op output alone does not verify that all required work was completed or that publication was possible.

Agent messages are omitted from this comment. The category uses structured run status, not interpretation of agent prose.

Generated from Design Decision Gate 🏗️ · routed: opus55 medium · ~11 AIC · ⌖ ~2 AIC · ⊞ 7.7K · ◷

🏗️ ADR gate enforced by Design Decision Gate 🏗️

@github-actions

github-actions Bot commented Nov 4, 2026 •

Copy link
Copy Markdown
Contributor

🧠 Matt Pocock Skills Reviewer has completed the skills-based review. ✅

🧠 Reviewed using Matt Pocock's skills by Matt Pocock Skills Reviewer

@github-actions

github-actions Bot commented Nov 4, 2026 •

Copy link
Copy Markdown
Contributor

✅ Test Quality Sentinel completed test quality analysis.

Test Quality Sentinel

Outcome: reported_no_action

The agent completed and reported no action. A no-op output alone does not verify that all required work was completed or that publication was possible.

Agent messages are omitted from this comment. The category uses structured run status, not interpretation of agent prose.

Generated from Test Quality Sentinel · routed: gpt56 max · ~1 AIC · ⌖ ~1 AIC · ⊞ 6.3K · ◷

🧪 Test quality analysis by Test Quality Sentinel

@github-actions

github-actions Bot commented Nov 4, 2026 •

Copy link
Copy Markdown
Contributor

✅ Ponytail Reviewer completed successfully!

Ponytail Reviewer

Outcome: reported_no_action

The agent completed and reported no action. A no-op output alone does not verify that all required work was completed or that publication was possible.

Agent messages are omitted from this comment. The category uses structured run status, not interpretation of agent prose.

Generated from Ponytail Reviewer · routed: gpt56 max · ~3 AIC · ⌖ ~1 AIC · ⊞ 118 · ◷

Generated by Ponytail Reviewer for #74946

@github-actions

github-actions Bot commented Nov 4, 2026

Copy link
Copy Markdown
Contributor

Comment Memory

Peek at saved memory (pr-code-quality-reviewer)
reviewed_at: 2026-11-04T20:11:02Z
review_event: COMMENT
top_themes: diagnostic accuracy in branch-protection 404 logging
files_reviewed: actions/setup/js/pr_helpers.cjs, actions/setup/js/pr_helpers.test.cjs, actions/setup/js/push_to_pull_request_branch.test.cjs, actions/setup/js/transport_integrity_handlers.test.cjs, docs/src/content/docs/reference/safe-outputs-pull-requests.md, pkg/workflow/app_token_permissions_validation_test.go, pkg/workflow/notify_comment_conclusion_helpers.go, pkg/workflow/notify_comment_test.go, pkg/workflow/safe_output_handlers.go, pkg/workflow/safe_outputs_permissions.go, pkg/workflow/safe_outputs_permissions_test.go, pkg/workflow/safe_outputs_steps.go
comment_count: 1

Note

This comment is managed by comment memory.

Expand the saved memory block to view or edit the persistent context for this thread.
Edit only the text inside the backtick fences; workflow metadata and the footer are regenerated automatically.

Learn more about comment memory

🔎 Code quality review by PR Code Quality Reviewer · copilot · gpt50 · ~3 AIC · ⌖ ~1 AIC · ⊞ 1.6K · ◷
Comment /review to run again

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Reviewed the changed code. No blocking correctness, security, or performance issues found.

Highlights
  • The branch API migration and App-token fallback are covered by targeted tests and preserve the intended least-privilege behavior.
  • One low-severity diagnostic issue was noted inline: the 404 log message still describes an unprotected branch rather than a missing branch.
  • Specialist findings about latent token-flag precedence, fallback scope masking, and ruleset coverage were not actionable from the changed code and were not published.

🔎 Code quality review by PR Code Quality Reviewer · copilot · gpt50 · ~3 AIC · ⌖ ~1 AIC · ⊞ 1.6K
Comment /review to run again

isBranchProtected = branchData.protected;
} catch (protectionError) {
const protectionStatus = protectionError && typeof protectionError === "object" && "status" in protectionError ? protectionError.status : undefined;
if (protectionStatus === 404) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

The 404 path now identifies a missing branch, but the emitted info message still says the branch has no protection rules, which can mislead incident triage about why the push proceeded.

💡 Keep the diagnostic aligned with the new API semantics

Change the core.info text in this branch to say that the branch was not found (or otherwise distinguish a missing branch from an unprotected branch). This preserves the new behavior while making logs accurately explain the decision.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Updated the 404-path diagnostic to report that the branch was not found and the push will proceed. Added an assertion for the message in pr_helpers.test.cjs; included in c74d7f0.

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Skills-Based Review 🧠

Applied /diagnosing-bugs and /tdd. I found no functional bugs in the token fallback or branch-protection paths. Requesting changes for stale user-facing text and one misleading log line.

✅ What I verified
  • The getBranch paths (404, 403, 5xx, protected true and false) are covered in pr_helpers.test.cjs. Targeted Go tests for App-token permissions and failure-step fallback pass, and gofmt is clean.
  • The fallback steps.safe-outputs-app-token.outputs.token || github.token resolves because the mint step uses that ID. The conclusion job grants issues: write when conclusionMayCreateIssue is true, so the github.token fallback has the scope it needs.
  • The steering-issue token resolves to the same App expression, so the new branch ignoring CustomToken does not drop a different credential.
  • JS tests were not run here because the npm registry TLS handshake failed in this environment.
🛠️ Stale references to the removed administration requirement (outside the diff, so no inline comment)
  1. pkg/parser/schemas/main_workflow_schema.json (around line 11523): the check-branch-protection description still says "requiring administration: read permission" and "Set to false to avoid requiring administration: read permission." This is user-facing schema text, so it should be reworded.
  2. pkg/workflow/push_to_pull_request_branch.go (line 42): the field comment still says "Set to false to avoid needing administration: read permission."
  3. docs/adr/28365-optional-branch-protection-check-for-push-to-pull-request-branch.md (lines 13, 17, 60, 74-76): the normative MUST text still requires administration: read. Add a superseding note or update it.

@copilot please address the review comments above.

🧠 Reviewed using Matt Pocock's skills by Matt Pocock Skills Reviewer · copilot · routed: haiku55 xhigh · ~9 AIC · ⌖ ~1 AIC · ⊞ 5.4K
Comment /matt to run again

Comment thread actions/setup/js/pr_helpers.cjs Outdated
if (protectionStatus === 404) {
// 404 means no protection rules – safe to proceed
// 404 means the branch does not exist – safe to proceed
core.info(`Branch "${branchName}" has no protection rules`);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

[/diagnosing-bugs] This 404 path now means the branch does not exist (getBranch), but the log still reads "has no protection rules". That is misleading when triaging a push to a missing branch. Report the actual outcome instead:

core.info(`Branch "${branchName}" not found; proceeding to push`);

@copilot please address this.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Updated the 404-path diagnostic to say Branch "<name>" not found; proceeding to push and added a regression assertion. Included in c74d7f0.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟡 Changes recommended

The host integration test still expects the removed permission, causing its exact-map comparison to fail, while the documentation omits ruleset-based branch blocking and the opt-out.

2 open issues
What changed in this PR

This PR removes the Administration permission requirement from gh-aw PR branch pushes and adds a token fallback so failure reporting can run when App token minting fails.

Changes:

  • Check the branch’s protected flag using the contents-readable branch API.
  • Enable github.token fallback for the two conclusion failure-reporting steps.
  • Update regression coverage, API mocks, and permission documentation.
File Description
pkg/​workflow/​safe_outputs_steps.go Add configurable token fallback for script steps.
pkg/​workflow/​safe_outputs_permissions.go Remove the obsolete protection-setting helper.
pkg/​workflow/​safe_outputs_permissions_test.go Expect push permissions without Administration.
pkg/​workflow/​safe_output_handlers.go Stop requesting Administration for branch pushes.
pkg/​workflow/​notify_comment_test.go Assert reporting fallback and unconditional execution.
pkg/​workflow/​notify_comment_conclusion_helpers.go Enable fallback for both failure reporters.
pkg/​workflow/​app_token_permissions_validation_test.go Cover App push permissions across protection settings.
docs/​src/​content/​docs/​reference/​safe-outputs-pull-requests.md Document the branch API and reduced permissions.
actions/​setup/​js/​transport_integrity_handlers.test.cjs Update the branch lookup mock.
actions/​setup/​js/​push_to_pull_request_branch.test.cjs Adapt protection and error-handling tests.
actions/​setup/​js/​pr_helpers.test.cjs Cover protected and unprotected branch flags.
actions/​setup/​js/​pr_helpers.cjs Replace the protection lookup with getBranch.

Review effort: Max (auto)

Comment on lines 515 to 516
}
if getCheckBranchProtection(safeOutputs.PushToPullRequestBranch) {
permissions.Set(PermissionAdministration, PermissionRead)
}
return permissions

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Removed the host-only permission-administration: read expectation so the integration test matches the new mint permission set. The tagged integration test passes; included in c74d7f0.

When `ignore-missing-branch-failure: true` is set, push failures caused by a deleted or missing PR branch return `skipped: true` instead of a hard failure. This is useful when the PR branch may have been deleted before the safe-output job runs (for example, on auto-merged PRs). Without this flag, a missing branch is a terminal error.

When `check-branch-protection: false` is set, the branch protection API pre-flight check is skipped. By default (`true`), the handler calls `GET /repos/{owner}/{repo}/branches/{branch}/protection` before pushing to detect whether the target branch is protected. This API call requires `administration: read`. If the token lacks that permission, the check logs a warning and continues (the GitHub platform still enforces protection at push time). Set `check-branch-protection: false` to suppress the warning and avoid the API call entirely.
When `check-branch-protection: false` is set, the branch protection pre-flight check is skipped. By default (`true`), the handler calls `GET /repos/{owner}/{repo}/branches/{branch}` and checks the `protected` flag before pushing. This API call requires only `contents: read`; GitHub App tokens do not need Administration permission. If the API returns 403, the check logs a warning and continues (GitHub still enforces protection at push time). Set `check-branch-protection: false` to avoid the API call entirely.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Documented that classic branch protection and rulesets both block the pre-flight—even when the proposed push could satisfy a ruleset—and that check-branch-protection: false opts out. Included in c74d7f0.

@gh-aw-bot

Copy link
Copy Markdown
Collaborator

Copilot assignment requested for the following outstanding work:

  1. Update this branch with the latest main using make merge-main, resolving any conflicts and preserving the intended changes.
  2. Review (actions/setup/js/pr_helpers.cjs:151): The 404 path now identifies a missing branch, but the emitted info message still says the branch has no protection rules, which can mislead incident triage about why the push proceeded. - Remove Administration requirement from PR branch pushes and preserve failure reporting #74946 (comment)
  3. Review (actions/setup/js/pr_helpers.cjs:153): [/diagnosing-bugs] This 404 path now means the branch does not exist (getBranch), but the log still reads "has no protection rules". That is misleading when triaging a push to a missing branch. Report the actual outcome instead: - Remove Administration requirement from PR branch pushes and preserve failure reporting #74946 (comment)
  4. Review (pkg/workflow/safe_output_handlers.go:516): The host case in pkg/cli/compile_safe_outputs_pr_credentials_integration_test.go:126–129 still adds permission-administration: read to the expected mint permissions. Removing the permission here makes TestCompileSafeOutputsPRCredentialsSpecificationIntegration/host fail its exact map comparison. Remove the host-only expectation so the integration test matches the new permission set. - Remove Administration requirement from PR branch pushes and preserve failure reporting #74946 (comment)
  5. Review (docs/src/content/docs/reference/safe-outputs-pull-requests.md:592): The branch API's protected state includes rulesets, so PR head branches covered only by a ruleset are now rejected even when a push would satisfy it, such as with signed commits. This paragraph explains the permission change but not the new blocking behavior. Document that both classic branch protection and rulesets block the pre-flight, and identify check-branch-protection: false as the opt-out. - Remove Administration requirement from PR branch pushes and preserve failure reporting #74946 (comment)

Once you start work, post this work summary as a PR comment, including the Sous-chef head, work, and state lines below, to record that the assignment is running. Apply the necessary fixes on this PR's existing branch, reply to each listed review thread and resolve it when addressed. Ignore feedback already answered or resolved; stop when only human review or CI remains. Do not merge or trigger CI.

Sous-chef requested-head: 96c7df1
Sous-chef requested-work: 7fcd12a053def7a2ea70aab0b0067375061b7d988c691525da1bbc85ffdc57bb e649ca992f746555f105cec426cfbc15400eb06c980a1330c9a7d7a3eadca91d efbe419501e9c1b82f6e929b3acf44c1b6464d63cc0760642d1200fe28492c03 fd5cbe33e0b51df20149a5415af35664504dbf4d9fc0bc438ddb54dddbe4020b
Sous-chef requested-state: 6fe202c8ebff8989978535abef1a2a32c421a2175417113a5c1e298ac30bea45

Generated by 👨🍳 PR Sous Chef · pi · haiku45 · ~18 AIC · ⌖ ~9 AIC · ⊞ 1.2K · ◷
Comment /souschef to run again

@pelikhan

pelikhan commented Nov 4, 2026

Copy link
Copy Markdown
Collaborator

@copilot run pr-finisher skill

Copilot AI commented Nov 4, 2026

Copy link
Copy Markdown
Contributor Author

Copilot assignment requested for the following outstanding work:

  1. Update this branch with the latest main using make merge-main, resolving any conflicts and preserving the intended changes....

Work is starting.

Sous-chef requested-head: 96c7df1
Sous-chef requested-work: 7fcd12a053def7a2ea70aab0b0067375061b7d988c691525da1bbc85ffdc57bb e649ca992f746555f105cec426cfbc15400eb06c980a1330c9a7d7a3eadca91d efbe419501e9c1b82f6e929b3acf44c1b6464d63cc0760642d1200fe28492c03 fd5cbe33e0b51df20149a5415af35664504dbf4d9fc0bc438ddb54dddbe4020b
Sous-chef requested-state: 6fe202c8ebff8989978535abef1a2a32c421a2175417113a5c1e298ac30bea45

I’m checking the requested branch update, review feedback, regression coverage, documentation, and local validation.

Copilot AI and others added 2 commits November 4, 2026 22:12
…uest-permission-issue

Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
@pelikhan

pelikhan commented Nov 5, 2026

Copy link
Copy Markdown
Collaborator

@copilot resolve the merge conflicts in this pull request

…uest-permission-issue

# Conflicts:
#	pkg/workflow/notify_comment_test.go

Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>

Copilot AI commented Nov 5, 2026 •

Copy link
Copy Markdown
Contributor Author

@copilot resolve the merge conflicts in this pull request

Resolved the conflict with main and committed the merge as 09a6962 (two-parent merge). The focused test and final change-scoped validation passed.

@copilot run pr-finisher skill

Ran the PR finisher pass. The branch now includes current main via merge commit 09a6962; local impacted validation passed. Full make lint still reports an unrelated wastedassign in a file unchanged from main. CI is stale and needs a maintainer re-trigger; the available tools do not expose review-thread resolution.

@gh-aw-bot

Copy link
Copy Markdown
Collaborator

@copilot

Copilot assignment requested for the following outstanding work:

  1. Update this branch with the latest main using make merge-main, resolving any conflicts and preserving the intended changes.
  2. Fix failing check JS Tests (shard 1/8) (FAILURE): https://github.com/github/gh-aw/actions/runs/41982621044/job/127096112762.

Once you start work, post this work summary as a PR comment without the leading Copilot mention, including the Sous-chef head, work, and state lines below, to record that the assignment is running. Apply the necessary fixes on this PR's existing branch, reply to each listed review thread and resolve it when addressed. Ignore feedback already answered or resolved; stop when only human review or CI remains. Do not merge or trigger CI.

Sous-chef requested-head: 09a6962
Sous-chef requested-work: be8977fed8539981a9de7f424c3c95730603faded3a88272a303c0b1b996a2af
Sous-chef requested-state: 4389c32b1b50669857f688df7953a703e4036d46e012c5031cc8ec0b7518794e

Generated by 👨🍳 PR Sous Chef · pi · haiku45 · ~8 AIC · ⌖ ~9 AIC · ⊞ 1.2K · ◷
Comment /souschef to run again

Copilot AI commented Nov 5, 2026

Copy link
Copy Markdown
Contributor Author

@copilot

Copilot assignment requested for the following outstanding work:...

Work is starting.

Sous-chef requested-head: 09a6962
Sous-chef requested-work: be8977fed8539981a9de7f424c3c95730603faded3a88272a303c0b1b996a2af
Sous-chef requested-state: 4389c32b1b50669857f688df7953a703e4036d46e012c5031cc8ec0b7518794e

Co-authored-by: gh-aw-bot <259018956+gh-aw-bot@users.noreply.github.com>
Copilot AI requested a review from gh-aw-bot November 5, 2026 07:28
@pelikhan
pelikhan merged commit 3636e00 into main Nov 5, 2026
56 checks passed
@pelikhan
pelikhan deleted the copilot/fix-token-request-permission-issue branch November 5, 2026 15:21
@github-actions

github-actions Bot commented Nov 6, 2026

Copy link
Copy Markdown
Contributor

🎉 This pull request is included in a new release.

Release: v1.2.1

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

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

4 participants