Repository navigation
Refactor permission-scope string conversion to validated inventory lookup - #31899
Merged
pelikhan merged 4 commits intoMay 13, 2026
Merged
Conversation
Closed
1 of 4 tasks
Agent-Logs-Url: https://github.com/github/gh-aw/sessions/d44562f6-6eb5-4dab-bed9-604d353a9856 Co-authored-by: gh-aw-bot <259018956+gh-aw-bot@users.noreply.github.com>
Agent-Logs-Url: https://github.com/github/gh-aw/sessions/d44562f6-6eb5-4dab-bed9-604d353a9856 Co-authored-by: gh-aw-bot <259018956+gh-aw-bot@users.noreply.github.com>
Contributor
|
Hey
When the implementation is ready, you can use this prompt to finish the work:
|
Agent-Logs-Url: https://github.com/github/gh-aw/sessions/d44562f6-6eb5-4dab-bed9-604d353a9856 Co-authored-by: gh-aw-bot <259018956+gh-aw-bot@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Refactor: collapse convertStringToPermissionScope switch to map lookup
Refactor permission-scope string conversion to validated inventory lookup
May 13, 2026
pelikhan
marked this pull request as ready for review
May 13, 2026 10:04
Contributor
There was a problem hiding this comment.
Pull request overview
This PR refactors convertStringToPermissionScope to remove a large identity switch and instead validate permission-scope strings against an inventory-derived set, with regression tests to ensure known scopes round-trip correctly.
Changes:
- Replaced the 49-case
switchinpkg/workflow/permissions.gowith an inventory-backed membership check (plus"all"meta-key fast-path). - Introduced a precomputed
validPermissionScopesset built from both permission-scope inventories (with an explicit inclusion forPermissionCopilotRequests). - Added a round-trip unit test to ensure all inventory scopes convert from string back to the same
PermissionScope.
Show a summary per file
| File | Description |
|---|---|
| pkg/workflow/permissions.go | Builds a validated scope lookup set and simplifies string→scope conversion logic. |
| pkg/workflow/github_app_permissions_validation_test.go | Adds round-trip coverage for scope conversion based on the inventory lists. |
| actions/setup/js/push_signed_commits.cjs | Adjusts formatting/indentation in an error message construction for unsupported commit shapes. |
Copilot's findings
Tip
Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
- Files reviewed: 2/3 changed files
- Comments generated: 1
Comment on lines
+311
to
+313
| } | ||
| } | ||
|
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
convertStringToPermissionScopewas a 49-case identity switch over string-backedPermissionScopeconstants, creating a third maintenance surface and easy drift risk when scopes change. This PR collapses conversion to inventory-backed validation and adds coverage for scope round-tripping.Conversion logic simplification
pkg/workflow/permissions.gowith:"all"fast-path preserving existing meta-key behaviorvalidPermissionScopessetPermissionScope(key)) for valid entriesSingle-source scope validation
validPermissionScopesis built from:GetAllPermissionScopes()GetAllGitHubAppOnlyScopes()PermissionCopilotRequestsinclusion (intentionally not granted byread-all, but still valid when explicitly configured)Targeted regression coverage
TestConvertStringToPermissionScope_RoundTripto assert:convertStringToPermissionScope(string(scope)) == scopeWarning
Firewall rules blocked me from connecting to one or more addresses (expand for details)
I tried to connect to the following addresses, but was blocked by firewall rules:
https://api.github.com/graphql/usr/bin/gh gh repo view --json owner,name --jq .owner.login + "/" + .name -nolocalimports -importcfg /tmp/go-build729306658/b441/importcfg -pack /tmp/go-build729306658/b441/_testmain.go(http block)/usr/bin/gh gh repo view --json owner,name --jq .owner.login + "/" + .name 64/pkg/tool/linux_amd64/vet n_test.go ctions-build/mairemote r 64/pkg/tool/linuremote1 ctio�� 2343691408/.github/workflows nomaly.go 64/pkg/tool/linux_amd64/link(http block)/usr/bin/gh gh pr list --repo github/gh-aw --state all --author app/github-actions --search created:2026-05-11T23:58:00Z..2026-05-12T00:05:00Z --limit 1 --json number --jq .[0].number(http block)https://api.github.com/orgs/owner/actions/secrets/usr/bin/gh gh api /orgs/owner/actions/secrets --jq .secrets[].name -c=4 -nolocalimports -importcfg /tmp/go-build729306658/b432/importcfg -pack /home/REDACTED/work/gh-aw/gh-aw/pkg/logger/doc.go /home/REDACTED/work/gh-aw/gh-aw/pkg/logger/logger.go(http block)/usr/bin/gh gh api /orgs/owner/actions/secrets --jq .secrets[].name ath ../../../.pr**/*.json infocmp bject.type] | @t../../../.prettierignore xterm-color gh /usr/bin/infocmp"prettier" --write '../../../**/*.json' '!../../../pkg/workflow/js/**/*.json' ---errorsas infocmp er xterm-color infocmp /usr/bin/infocmp ithub-script/gitgit gh bject.type] | @t/tmp/gh-aw-test-runs/20260513-095129-40465/test-source-field-variant-2228226758/.github/workflows infocmp(http block)/usr/bin/gh gh api /orgs/owner/actions/secrets --jq .secrets[].name ath ../../../.pr**/*.json infocmp bject.type] | @t../../../.prettierignore DefaultBranchFrosh DefaultBranchFro-c .cfg infocmp er ithub-script/git/ref/tags/v9 erignore h 5129-40465/test-git infocmp 1/x64/bin/node infocmp(http block)https://api.github.com/orgs/test-owner/actions/secrets/usr/bin/gh gh api /orgs/test-owner/actions/secrets --jq .secrets[].name on' --ignore-path ../../../.prettierignore(http block)/usr/bin/gh gh api /orgs/test-owner/actions/secrets --jq .secrets[].name 91807259/001' 91807259/001' sv /ref/tags/v9 --jq sv gh er /ref/tags/v9(http block)/usr/bin/gh gh api /orgs/test-owner/actions/secrets --jq .secrets[].name ath ../../../.pr--ignore-path(http block)https://api.github.com/repos/actions/ai-inference/git/ref/tags/v1/usr/bin/gh gh api /repos/actions/ai-inference/git/ref/tags/v1 --jq [.object.sha, .object.type] | @tsv -unreachable=false /tmp/go-build729306658/b234/vet.cfg trepo.git h ../../../.pretgh(http block)Agent-Logs-Url: REDACTED 64/bin/gofmt 801519/001 -buildtags /usr/bin/git 64/bin/gofmt -1 ithub-script/git/ref/tags/v9 atted/golang/pkg/flatted/flatted.go o` (http block)
Agent-Logs-Url: REDACTED 64/pkg/tool/linux_amd64/link t0 -buildtags` (http block)
Agent-Logs-Url: REDACTED ndor/bin/bash xterm-color` (http block)