Skip to content

Remove unused 'pull-requests: read' permission from the labels workflow - #28241

Open
吴旭云 (yuunnn) wants to merge 1 commit into
PowerShell:masterfrom
yuunnn:fix/labels-workflow-unused-permission
Open

吴旭云 (yuunnn) wants to merge 1 commit into
PowerShell:masterfrom
yuunnn:fix/labels-workflow-unused-permission

Conversation

@yuunnn

Copy link
Copy Markdown

PR Summary

Fixes #28194.

Verify PR Labels declares pull-requests: read, but no step in the workflow needs it. The only steps are:

  • actions/checkout, which requires contents: read.
  • actions/github-script, whose inline script makes no API call. It reads context.payload.pull_request.labels, which is already part of the webhook payload the runner received. Reading it does not touch the REST API, so no permission authorises anything.

pull-requests: read would only be required if the script fetched the labels through the API instead, for example pulls.get or issues.listLabelsOnIssue. It does not, so contents: read is the minimal sufficient set.

PR Context

Removing the scope keeps the workflow working and reduces the token permissions granted to the job, in line with the principle of least privilege. The token minted for this workflow is available to every step, including the third-party actions pinned in it.

PR Checklist

Validation

The change only removes a permission that is not consumed. The verify-labels job is guarded by if: github.repository_owner == 'PowerShell', so it does not run on forks; on the upstream repository it continues to evaluate context.payload.pull_request.labels exactly as before, and actions/checkout keeps the contents: read it needs.

Copilot AI balanced review requested due to automatic review settings October 20, 2026 09:37
@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
There may be pipelines that require an authorized user to comment /azp run to run.

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.

🟢 Approval recommended

Label validation reads the webhook payload without API calls, and checkout retains its required permission.

No open issues 🎉

What changed in this PR

Addresses #28194 by reducing token permissions in the label-validation workflow.

Changes:

  • Removes unused pull-requests: read.
  • Retains contents: read for checkout without changing label validation.
File Description
.github/​workflows/​labels.yml Removes an unnecessary token permission.

Review effort: Balanced

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.

Workflow labels.yml grants pull-requests: read that no step uses

2 participants