fix: preserve GraphQL error type for scope errors in handleResponse#12913
fix: preserve GraphQL error type for scope errors in handleResponse#12913yuvrajangadsingh wants to merge 1 commit intocli:trunkfrom
Conversation
Fixes cli#12904 handleResponse was rewriting INSUFFICIENT_SCOPES GraphQL errors into plain fmt.Errorf strings via GenerateScopeErrorForGQL. This destroyed the original error message that ProjectsV2IgnorableError relies on to silently suppress read:project scope errors. Removed the GenerateScopeErrorForGQL call from handleResponse so scope errors flow through as GraphQLError like any other GraphQL error. Project commands still get user-friendly scope messages through their own handleError in pkg/cmd/project/shared/queries.
|
Thanks for your pull request! Unfortunately, it doesn't meet the minimum requirements for review:
Please update your PR to address the above. Requirements:
This PR will be automatically closed in 7 days if these requirements are not met. |
|
@BagToad @camjac251 this is a regression from #12596 (merged last month) that breaks gh pr view, gh pr edit, gh issue view for any token without read:project scope. issue #12904 was just filed today so it probably needs the help wanted label. the fix is 4 lines removed + a regression test. |
|
First, huge thanks for your support in digging this problem and being proactive to submit a fix for it, @yuvrajangadsingh! 🙏 I believe we have to close this PR as the original enhancements made in those recent PRs were not actually in the right direction (not just bogus I mean). So, @williammartin and I decided to revert those two PRs in #12915 and #12914. Quoting from @williammartin:
|
Fixes #12904
PR #12596 added
GenerateScopeErrorForGQL()insidehandleResponse(), which rewritesINSUFFICIENT_SCOPESGraphQL errors into plainfmt.Errorfstrings before callers see them. This brokeProjectsV2IgnorableError()which checks for the original API substring to silently suppressread:projectscope errors.After the rewrite,
gh pr view,gh pr edit,gh issue viewetc. all fatally error instead of gracefully ignoring the missing project scope.The fix removes
GenerateScopeErrorForGQLfromhandleResponse()so scope errors flow through asGraphQLErrorlike any other GraphQL error.ProjectsV2IgnorableErrorcan then match the original message and suppress it as intended.gh projectcommands still get user-friendly scope messages through their ownhandleErrorinpkg/cmd/project/shared/queries, which already callsGenerateScopeErrorForGQLindependently.Changes:
api/client.go: removed scope error rewriting fromhandleResponseapi/queries_projects_v2_test.go: added regression test that verifies scope errors remain ignorable after passing throughhandleResponse