Repository navigation
Description
Describe the bug
When gh release create receives an HTTP 404, it checks whether the token carries the workflow scope and, if not, replaces the error with a hint about requesting that scope. The scope check is broken, so it reports "no workflow scope" for essentially every OAuth token — including tokens that plainly do have the scope.
Two consequences:
- Users are told to run
gh auth refresh -s workflowwhen they already haveworkflow. Running it changes nothing, so there is no way to make the message go away. - More importantly, the real reason for the 404 is masked. A typo in the repo name, a repo that does not exist, or a lack of push access all surface as a scope problem instead of
HTTP 404: Not Found.
The cause is in tokenHasWorkflowScope in pkg/cmd/release/create/http.go:
return slices.Contains(strings.Split(scopes, ","), "workflow")The X-Oauth-Scopes response header is comma-space separated, so splitting on , alone yields elements with a leading space: ["gist", " project", " read:org", " repo", " user", " workflow"]. Only the first element ever matches a bare scope name, and the header lists scopes in sorted order, so workflow is effectively never first. The comparison therefore fails no matter what the token holds.
Other scope parsers in this repo already account for this — generateScopesSuggestion in api/client.go does strings.TrimSpace(s) on each element, and the pkg/cmd/auth/status tests stub the header as "repo, read:org" with the space. tokenHasWorkflowScope is the one place that omits the trim.
Affected version
gh version 2.96.0 (2026-07-02)
https://github.com/cli/cli/releases/tag/v2.96.0
Also reproduces on a build of current trunk.
Steps to reproduce the behavior
Authenticate with an OAuth token that includes the workflow scope (gh auth login via the web flow grants it by default; gh auth refresh -s workflow otherwise), then point gh release create at a repository that does not exist:
$ GH_DEBUG=api GH_REPO=cli/definitely-not-a-real-repo-wm-9f3a gh release create v0.0.0 --notes testA single run shows the whole problem — the scope the token actually has, the real reason for the failure, and the conclusion gh draws instead.
Expected vs actual behavior
Expected: because the token has the workflow scope, the scope-specific hint should be suppressed and the underlying error reported, e.g. HTTP 404: Not Found (https://api.github.com/repos/cli/definitely-not-a-real-repo-wm-9f3a/releases).
Actual: the 404 is swallowed and replaced with a workflow-scope hint that does not apply and cannot be acted on.
Note the hint is genuinely useful in the case it was written for: creating a release whose tag introduces workflow file changes does 404 without the workflow scope, and the API gives no other signal. The problem is only that the guard meant to limit the hint to that case never holds.
Logs
$ GH_DEBUG=api GH_REPO=cli/definitely-not-a-real-repo-wm-9f3a gh release create v0.0.0 --notes test
[git tag --list v0.0.0 --format=%(contents)]
* Request at 2026-08-04 15:34:04.695914 +0200 CEST m=+0.020581376
* Request to https://api.github.com/repos/cli/definitely-not-a-real-repo-wm-9f3a/releases
> POST /repos/cli/definitely-not-a-real-repo-wm-9f3a/releases HTTP/1.1
> Host: api.github.com
> Accept: application/vnd.github.merge-info-preview+json, application/vnd.github.nebula-preview
> Authorization: token ████████████████████
> Content-Length: 68
> Content-Type: application/json; charset=utf-8
> Time-Zone: Europe/Amsterdam
> User-Agent: GitHub CLI 2.96.0 Agent/github_copilot_app_agent
> X-Github-Api-Version: 2022-11-28
{
"body": "test",
"draft": false,
"prerelease": false,
"tag_name": "v0.0.0"
}
< HTTP/2.0 404 Not Found
< Access-Control-Allow-Origin: *
< Access-Control-Expose-Headers: ETag, Link, Location, Retry-After, X-GitHub-OTP, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Used, X-RateLimit-Resource, X-RateLimit-Reset, X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Poll-Interval, X-GitHub-Media-Type, X-GitHub-SSO, X-GitHub-Request-Id, Deprecation, Sunset, Warning
< Content-Security-Policy: default-src 'none'
< Content-Type: application/json; charset=utf-8
< Date: Tue, 04 Aug 2026 13:34:04 GMT
< Referrer-Policy: origin-when-cross-origin, strict-origin-when-cross-origin
< Server: github.com
< Strict-Transport-Security: max-age=31536000; includeSubdomains; preload
< Vary: Accept-Encoding, Accept, X-Requested-With
< X-Accepted-Oauth-Scopes: repo
< X-Content-Type-Options: nosniff
< X-Frame-Options: deny
< X-Github-Api-Version-Selected: 2022-11-28
< X-Github-Edge-Region: fra
< X-Github-Media-Type: github.v3; param=merge-info-preview.nebula-preview; format=json
< X-Github-Request-Id: 869B:13D926:7E44EFB:789D20F:6A71EA4C
< X-Oauth-Client-Id: Ov23ctr1Udn5GokVCVJf
< X-Oauth-Scopes: gist, project, read:org, repo, user, workflow
< X-Ratelimit-Limit: 15000
< X-Ratelimit-Remaining: 14978
< X-Ratelimit-Reset: 1785850871
< X-Ratelimit-Resource: core
< X-Ratelimit-Used: 22
< X-Xss-Protection: 0
{
"message": "Not Found",
"documentation_url": "https://docs.github.com/rest/releases/releases#create-a-release",
"status": "404"
}
* Request took 239.281167ms
! Failed to create release, "workflow" scope may be required.
To request it, run:
gh auth refresh -h github.com -s workflowThree things to note in that transcript:
X-Oauth-Scopeson the failing response ends inworkflow, so the token has the scope and the header carrying that fact reachedghintact. Note the,separator.- The body says
"message": "Not Found"— the repository does not exist. That is the error the user needed to see. ghnevertheless prints theworkflow-scope hint and discards the 404.
Suggested fix
Trim each element before comparing, matching what api/client.go already does:
for _, s := range strings.Split(scopes, ",") {
if strings.TrimSpace(s) == "workflow" {
return true
}
}
return falseWorth adding a test case with the realistic "repo, workflow" spacing — the existing fixtures for this function use unspaced values such as repo,read:org,workflow, which is why the bug was not caught.
Activity
cli-triage commentedon Aug 4, 2026
This is a well-documented bug in
tokenHasWorkflowScopeinpkg/cmd/release/create/http.go. The comma-space-separatedX-Oauth-Scopesheader is split on,alone, leaving leading spaces on each element except the first, soworkflowis never matched. No duplicates found.Suggesting
priority-2(affects multiple users, no workaround, masks real errors like 404s from typos or missing repos) andgh-release(scoped to the release command).fix(release create): trim spaces when parsing X-Oauth-Scopes