Thanks to visit codestin.com
Credit goes to github.com

Skip to content

fix(check_membership): skip roles check for allowlisted bots to eliminate spurious permission warning#34064

Merged
pelikhan merged 8 commits into
mainfrom
copilot/fix-bots-allowlist-actor-warning
May 22, 2026
Merged

fix(check_membership): skip roles check for allowlisted bots to eliminate spurious permission warning#34064
pelikhan merged 8 commits into
mainfrom
copilot/fix-bots-allowlist-actor-warning

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented May 22, 2026

When a bot in the on.bots: allowlist triggers a workflow, pre_activation/check_membership was emitting a User permission 'none' does not meet requirements: admin, maintainer, write warning even though activation succeeded — because the roles check ran before the bot allowlist check.

Changes

  • check_membership.cjs: Move the bots allowlist evaluation before checkRepositoryPermission. If the actor matches the allowlist, bot-status verification runs immediately and checkRepositoryPermission is never called (eliminating the warning). The roles check only runs for actors not in the allowlist. The bot_not_active path now unconditionally uses "bot" for user_permission since there is no longer an initial permission-check result to fall back on.

  • check_membership.test.cjs: Remove the now-unnecessary initial getCollaboratorPermissionLevel mock from all bots-allowlist test cases. Add a regression test asserting no does not meet requirements warning is emitted when an allowlisted bot (e.g. github-actions[bot]) triggers the workflow.

Before (two API calls, warning emitted on first):

checkRepositoryPermission("github-actions[bot]", ...)  // ⚠ "permission 'none' does not meet requirements"
→ isAllowedBot → checkBotStatus → ✅ authorized_bot

After (one API call, no warning):

isAllowedBot → checkBotStatus  // ✅ authorized_bot — roles check skipped entirely

Copilot AI and others added 3 commits May 22, 2026 16:26
Co-authored-by: pelikhan <[email protected]>
…ssion warning

When an actor matches the `bots:` allowlist in `check_membership.cjs`, move the
bot-status verification before the repository permission check. This eliminates
the spurious "User permission 'none' does not meet requirements: admin, maintainer,
write" warning that was previously emitted by `checkRepositoryPermission` even
though the bot was subsequently authorized via the bots allowlist.

A bot listed in `on.bots:` is an explicit grant; the roles mismatch (bots typically
have "none" repo permission) is expected and not actionable. Checking the bots
allowlist first avoids the misleading warning entirely.

Also remove the now-unnecessary initial permission check call from the existing
bots-allowlist tests and add a regression test that asserts the warning is not
emitted when `github-actions[bot]` (or any allowlisted bot) triggers the workflow.

Co-authored-by: pelikhan <[email protected]>
Copilot AI changed the title [WIP] Fix spurious 'permission none does not meet requirements' warning in workflow fix(check_membership): skip roles check for allowlisted bots to eliminate spurious permission warning May 22, 2026
Copilot AI requested a review from pelikhan May 22, 2026 16:31
@pelikhan pelikhan marked this pull request as ready for review May 22, 2026 17:29
Copilot AI review requested due to automatic review settings May 22, 2026 17:29
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

This PR adjusts the pre-activation membership validation flow to avoid emitting a misleading “permission does not meet requirements” warning when an allowlisted bot triggers a workflow, by checking the bot allowlist before performing any repository permission/roles check. It also updates a couple of workflow/action lock artifacts that appear unrelated to the membership-change goal as currently described.

Changes:

  • Reordered bot allowlist evaluation in check_membership.cjs so allowlisted bots go directly to bot-status verification and skip the repository roles/permission check (removing the spurious warning).
  • Updated check_membership tests to reflect the new call order and added a regression test asserting no roles-mismatch warning for allowlisted bots.
  • Updated workflow/action lockfiles (e.g., docker/setup-buildx-action pin; developer-docs workflow schedule), which should be confirmed as intentional and ideally called out in the PR description.
Show a summary per file
File Description
actions/setup/js/check_membership.cjs Moves allowlisted-bot handling ahead of repo permission checks; adjusts bot_not_active output.
actions/setup/js/check_membership.test.cjs Updates mocks for new call ordering; adds regression test for warning suppression.
.github/workflows/release.lock.yml Updates pinned SHA for docker/setup-buildx-action in the release workflow lock.
.github/workflows/developer-docs-consolidator.lock.yml Updates developer-docs consolidator workflow lock (includes schedule change to weekly).
.github/aw/actions-lock.json Adds lock entry for docker/setup-buildx-action@v4 matching the updated workflow pin.

Copilot's findings

Tip

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

Comments suppressed due to low confidence (1)

.github/workflows/release.lock.yml:1536

  • Second occurrence of the docker/setup-buildx-action pin update in this workflow lockfile; if the action bump isn’t part of the intended scope of this PR, consider splitting it out so release workflow dependency updates can be reviewed/rolled back independently of the membership logic change.
      - name: Setup Docker Buildx
        uses: docker/setup-buildx-action@d7f5e7f509e45cec5c76c4d5afdd7de93d0b3df5 # v4
      - name: Log in to GitHub Container Registry
  • Files reviewed: 5/5 changed files
  • Comments generated: 4

Comment thread actions/setup/js/check_membership.cjs Outdated
// Checking bots first also avoids a spurious "permission does not meet requirements"
// warning that would otherwise be emitted by the roles check before authorization succeeds.
if (allowedBots.length > 0 && isAllowedBot(actorToValidate, allowedBots)) {
core.info(`Checking if actor '${actorToValidate}' is in allowed bots list: ${allowedBots.join(", ")}`);
Comment on lines 69 to +71
schedule:
- cron: "19 13 * * *"
# Friendly format: daily (scattered)
- cron: "19 13 * * 6"
# Friendly format: weekly (scattered)
Comment on lines 1374 to 1376
- name: Setup Docker Buildx (pre-validation)
uses: docker/setup-buildx-action@4d04d5d9486b7bd6fa91e7baf45bbb4f8b9deedd # v4.0.0 (source v4)
uses: docker/setup-buildx-action@d7f5e7f509e45cec5c76c4d5afdd7de93d0b3df5 # v4
- name: Build Docker image (validation only)
Comment on lines +151 to +155
"docker/setup-buildx-action@v4": {
"repo": "docker/setup-buildx-action",
"version": "v4",
"sha": "d7f5e7f509e45cec5c76c4d5afdd7de93d0b3df5"
},
Comment thread actions/setup/js/check_membership.cjs Outdated
// mismatch (bots typically have "none" repo permission) is expected and not actionable.
// Checking bots first also avoids a spurious "permission does not meet requirements"
// warning that would otherwise be emitted by the roles check before authorization succeeds.
if (allowedBots.length > 0 && isAllowedBot(actorToValidate, allowedBots)) {
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

@copilot refactor to helper function and add more tests

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.

Done in the latest commit. The inline bot allowlist block in main() is now extracted into a named async helper checkBotAllowlistAuthorization — it returns { handled: true } when a final decision (authorized/denied) is reached and { handled: false } to fall through to the roles check. The helper is also exported for direct testability.

New tests added:

  • actor matches the second entry in a multi-bot allowlist
  • allowlist entry with [bot] suffix is equivalent to the slug form
  • bot_not_active result explicitly sets user_permission to "bot"
  • non-404 bot-status failure produces bot_not_active (not a silent roles fallthrough)

Also fixed the log ordering noted in the review: the "matched the allowed bots list" message is now emitted once, after isAllowedBot() confirms the match, instead of the previous two-line log sequence that appeared after the check had already passed.

Extract the inline bot allowlist block from main() into a named async
helper function `checkBotAllowlistAuthorization`. The helper:
- Returns { handled: false } when the allowlist is empty, the actor
  does not match, or the bot-status check fails entirely (falls through
  to the standard roles check)
- Returns { handled: true } once a final authorization decision is
  reached (authorized_bot or bot_not_active)
- Fixes log ordering: "Actor matched the allowed bots list: ..." is
  now emitted after the isAllowedBot() match is confirmed (not redundantly
  after confirming it again)

Export the helper for direct testability.

New tests added:
- second entry in a multi-bot allowlist is matched
- allowlist entry with [bot] suffix is treated as equivalent to slug
- bot_not_active result explicitly sets user_permission to "bot"
- non-404 bot status failure yields bot_not_active (not a roles fallthrough)

Co-authored-by: pelikhan <[email protected]>
Copilot AI requested a review from pelikhan May 22, 2026 17:48
@pelikhan
Copy link
Copy Markdown
Collaborator

@copilot review all comments

Co-authored-by: pelikhan <[email protected]>
Copy link
Copy Markdown
Contributor Author

Copilot AI commented May 22, 2026

@copilot review all comments

Reviewed all open comments:

  1. Log ordering (line 164) — already fixed in a prior commit: the "Actor matched the allowed bots list" message is now emitted once, after isAllowedBot() has confirmed the match.

  2. Helper function + tests (line 163) — already done in commit 5050e0b: the inline block is extracted into the exported checkBotAllowlistAuthorization helper; four new test cases were added (second allowlist entry, [bot] suffix equivalence, bot_not_active sets user_permission:"bot", non-404 failure yields bot_not_active).

  3. Unrelated lockfile changes (developer-docs-consolidator schedule, release.lock.yml docker/setup-buildx-action bump, actions-lock.json, action_pins.json) — reverted in commit 7701e79. The PR now only touches check_membership.cjs and check_membership.test.cjs.

@pelikhan
Copy link
Copy Markdown
Collaborator

Copy link
Copy Markdown
Contributor Author

Copilot AI commented May 22, 2026

@copilot lint js https://github.com/github/gh-aw/actions/runs/26304131778/job/77436416369?pr=34064

Fixed in the latest commit — ran Prettier on check_membership.test.cjs to resolve the formatting issues flagged by lint-js.

@pelikhan pelikhan merged commit 1ec6d7b into main May 22, 2026
@pelikhan pelikhan deleted the copilot/fix-bots-allowlist-actor-warning branch May 22, 2026 18:23
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.

Spurious 'permission none does not meet requirements' warning when bots: allowlist actor triggers workflow

3 participants