Repository navigation
Remove Administration requirement from PR branch pushes and preserve failure reporting - #74946
Conversation
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
|
✅ PR Code Quality Reviewer completed the code quality review.
|
|
✅ 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: 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.
|
|
🧠 Matt Pocock Skills Reviewer has completed the skills-based review. ✅
|
|
✅ Test Quality Sentinel completed test quality analysis. Test Quality SentinelOutcome: 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.
|
|
✅ Ponytail Reviewer completed successfully! Ponytail ReviewerOutcome: 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.
|
Comment MemoryPeek at saved memory (pr-code-quality-reviewer)Note This comment is managed by comment memory.Expand the saved memory block to view or edit the persistent context for this thread.
|
There was a problem hiding this comment.
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) { |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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
getBranchpaths (404, 403, 5xx, protected true and false) are covered inpr_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.tokenresolves because the mint step uses that ID. The conclusion job grantsissues: writewhenconclusionMayCreateIssueis true, so thegithub.tokenfallback has the scope it needs. - The steering-issue token resolves to the same App expression, so the new branch ignoring
CustomTokendoes 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)
pkg/parser/schemas/main_workflow_schema.json(around line 11523): thecheck-branch-protectiondescription 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.pkg/workflow/push_to_pull_request_branch.go(line 42): the field comment still says "Set to false to avoid needing administration: read permission."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 requiresadministration: 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
| 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`); |
There was a problem hiding this comment.
[/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.
There was a problem hiding this comment.
Updated the 404-path diagnostic to say Branch "<name>" not found; proceeding to push and added a regression assertion. Included in c74d7f0.
There was a problem hiding this comment.
🟡 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
protectedflag using the contents-readable branch API. - Enable
github.tokenfallback 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)
| } | ||
| if getCheckBranchProtection(safeOutputs.PushToPullRequestBranch) { | ||
| permissions.Set(PermissionAdministration, PermissionRead) | ||
| } | ||
| return permissions |
There was a problem hiding this comment.
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. |
There was a problem hiding this comment.
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.
|
Copilot assignment requested for the following outstanding work:
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
|
|
@copilot run pr-finisher skill |
Work is starting. Sous-chef requested-head: 96c7df1 I’m checking the requested branch update, review feedback, regression coverage, documentation, and local validation. |
…uest-permission-issue Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
|
@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>
Resolved the conflict with
Ran the PR finisher pass. The branch now includes current |
|
Copilot assignment requested for the following outstanding work:
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
|
Work is starting. Sous-chef requested-head: 09a6962 |
Co-authored-by: gh-aw-bot <259018956+gh-aw-bot@users.noreply.github.com>
|
🎉 This pull request is included in a new release. Release: |


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.repos.getBranch().protectedinstead ofgetBranchProtection; remove the Administration request while preserving existing error handling.