Repository navigation
Open
Labels
bugSomething isn't workinggh-prrelating to the gh pr commandpitchpitched internally for prioritisationpriority-3Affects a small number of users or is largely cosmetic
Description
Describe the bug
I was trying to run gh pr update-branch on a PR I've submitted to the current repo cli/cli but I got this error message:
GraphQL: refusing to allow an OAuth App to create or update workflow `.github/workflows/lint.yml` without `workflow` scope (updatePullRequestBranch)
When I refreshed my auth scopes with gh auth refresh --scopes workflow, it worked.
Please correct me if I'm wrong to jumping to conclusion too fast, but I think we should either:
- Add the
workflowscope to minimum scopes. This seems like the easiest solution because the user doesn't have to do some extra steps, but could also be considered against the minimum access policy. - Detect this specific error and instruct the user to refresh their token with the required scope. We also might want to include this in the
gh pr update-branchcommand docs. The same approach has been implemented here and here.
Steps to reproduce the behavior
I'm not quite sure that the steps below will reproduce the issue.
- Create a fork of one of your repositories that has a workflow triggered by
pushevents. To be able to create a fork, you have to make it under a new temporary organization (or user account) because normally you cannot fork your own repos. - Submit a PR from a branch on your fork to the original repo.
- Push some non-conflicting commits to your original repo's
mainbranch. This is required, so thatgh pr update-branchcan finish its job and not bail out with aPR branch is already up-to-datemessage. - Create a fine-grained PAT that only has access to your forked repo (under your organization).
- Run
gh auth loginand use the created token. - Run
gh pr update-branch -R <original repo> <PR number>. - See the error.
Expected vs actual behavior
User expects the last command to work (i.e., see the PR branch updated) or a message that says what scopes they need to add to their auth token. Instead, they see the following error:
GraphQL: refusing to allow an OAuth App to create or update workflow `.github/workflows/lint.yml` without `workflow` scope (updatePullRequestBranch)
Reacted by Niklas Keller
Metadata
Metadata
Assignees
Labels
bugSomething isn't workinggh-prrelating to the gh pr commandpitchpitched internally for prioritisationpriority-3Affects a small number of users or is largely cosmetic
Activity
williammartin commentedon Jul 28, 2024
When you
gh authlogin which protocol did you choose? I would expect you getworkflowscope withhttps, and if you chosesshand then happened to clone withhttpsthen yeh, I could see how you might run into this.babakks commentedon Jul 28, 2024
Yeah, I used
sshfor login, but I've cloned the repo withssh. This is thegit remote -vresult:williammartin commentedon Jul 29, 2024
Yeh I guess that makes sense. You would be able to
git pusha change with workflow changes (because it would use yoursshkey) but you couldn't use an API endpoint that involves merging a workflow change because your scopes don't have it. I agree that we should probably just default to addingworkflowscope here in all cases, I think it's a weird edge case and hard to uncover.That said, if you could share the
GH_DEBUG=apioutput that would be handy. We do have an oauth scope detection mechanism based on headers but I suspect what's happening here is that the API isn't being faithful. It's kind of a weird quirk that depending on the content of the changes you may need this scope or not, and so I don't think it's reflected in the spec.babakks commentedon Jul 29, 2024
If you think the
workflowscope should be added to the minimum-scopes at login, I'd be happy to submit a PR for that. But what about the existing sessions? I mean, those users who have already logged in, and won't get theworkflowscope until they login again. Shouldn't we check for the error message and instruct them to add the required scope (by usinggh auth refresh)?With
GH_DEBUG=apiI tried to replicate it but couldn't. I mean, I logged out and logged in again with the same choices to ensure I don't have the
workflowscope. Below is the result withGH_DEBUG=api.I'm curious because the response header
X-Oauth-Scopesis alwaysgist, read:org, repo. So, I really don't have theworkflowscope but this time everything worked. Also, thelintworkflow (which triggering of it was the source of error last time) has been triggered again, this time with no issues.williammartin commentedon Jul 30, 2024
I'll look at this when I come back from vacation in mid-August. Don't think there's much rush. The message at least gives direction even if it's not the best.
jkylekelly commentedon Mar 6, 2026
@williammartin any chance we'll be seeing this soon?