Skip to content

Revert "fix: clarify scope error while creating issues for projects"#12915

Merged
williammartin merged 1 commit intotrunkfrom
revert-12596-fix/clarify-scope-error
Mar 12, 2026
Merged

Revert "fix: clarify scope error while creating issues for projects"#12915
williammartin merged 1 commit intotrunkfrom
revert-12596-fix/clarify-scope-error

Conversation

@williammartin
Copy link
Member

@williammartin williammartin commented Mar 12, 2026

Description

Reverts #12596

Fixes #12904

This PR introduced a change that adjusted the stringified error message returned in GQL response when there were missing scopes. However, that error message was interrogated by ProjectsV2IgnorableError in order to gracefully degrade the experience on pr and issue view commands when read:projects was missing.

We could move this forward, but I actually think the implementation in that PR was incorrect because it previously showed an error message that made sense for personal access tokens and was changed to a message that only made sense for OAuth tokens. And so it just sort of swapped the problem around. I'm gonna reopen that issue, but if we were to address it again we would need to interrogate the type of token or provide an error message that covered both cases.

Acceptance Test

Before

➜  cli git:(trunk) GH_ACCEPTANCE_SCRIPT=pr-view.txtar GH_ACCEPTANCE_HOST=github.com GH_ACCEPTANCE_ORG=gh-acceptance-testing GH_ACCEPTANCE_TOKEN=$(gh auth token) go test -tags=acceptance -run ^TestPullRequests$ ./acceptance
--- FAIL: TestPullRequests (0.00s)
    --- FAIL: TestPullRequests/pr-view (9.67s)
        testscript.go:584: # Use gh as a credential helper (0.735s)
            # Create a repository with a file so it has a default branch (1.273s)
            # Defer repo cleanup (0.000s)
            # Clone the repo (1.914s)
            # Prepare a branch to PR (1.181s)
            # Create the PR (2.270s)
            # View the PR (2.249s)
            > exec gh pr view $PR_URL
            [stderr]
            error: your authentication token is missing required scopes [read:project]
            To request it, run:  gh auth refresh -s read:project
            [exit status 1]
            FAIL: testdata/pr/pr-view.txtar:28: unexpected command failure

FAIL
FAIL	github.com/cli/cli/v2/acceptance	10.296s
FAIL

After

➜  cli git:(revert-12596-fix/clarify-scope-error) ✗ GH_ACCEPTANCE_SCRIPT=pr-view.txtar GH_ACCEPTANCE_HOST=github.com GH_ACCEPTANCE_ORG=gh-acceptance-testing GH_ACCEPTANCE_TOKEN=$(gh auth token) go test -tags=acceptance -run ^TestPullRequests$ ./acceptance
ok  	github.com/cli/cli/v2/acceptance	10.317s

Copy link
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 reverts #12596, which had added a centralized GenerateScopeErrorForGQL function in api/client.go to detect INSUFFICIENT_SCOPES GraphQL errors and generate user-friendly scope error messages. The revert removes this centralized handling, leaving the original scope error handling in pkg/cmd/project/shared/queries/queries.go intact.

Changes:

  • Removes GenerateScopeErrorForGQL and requiredScopesFromServerMessage functions from api/client.go, along with the call site in handleResponse
  • Removes associated test cases from api/client_test.go
  • Removes now-unused imports (pkg/set, go-gh/v2/pkg/api)

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
api/client.go Removes GenerateScopeErrorForGQL, requiredScopesFromServerMessage, and the scope error interception in handleResponse
api/client_test.go Removes tests for GenerateScopeErrorForGQL and requiredScopesFromServerMessage, and the unused import

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

Copy link
Member

@babakks babakks left a comment

Choose a reason for hiding this comment

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

LGTM! reviewed in sync.

@williammartin williammartin merged commit 37800dd into trunk Mar 12, 2026
36 checks passed
@williammartin williammartin deleted the revert-12596-fix/clarify-scope-error branch March 12, 2026 12:06
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 missing read:project scope warnings

3 participants