Thanks to visit codestin.com
Credit goes to github.com

Skip to content

gh release create works for some commit hashes but gets weird 404 for others #9773

@idanarye

Description

@idanarye

Describe the bug

gh release create command works for some commit hashes but not for other. For the ones it doesn't work, it complains about getting 404 when accessing the https://api.github.com/repos/<owner>/<repo>/releases API endpoint..

Steps to reproduce the behavior

Since I don't know what causes it to break for some commits but not for others, I can't replicate it from a fresh repository. You'll have to use one of my repositories.

  1. Fork my repository https://github.com/idanarye/bevy-yoetz
  2. git clone your fork and cd into the worktree.
  3. Set the default repository for the workdir with gh repo set-default
  4. Run the following command to create a release from commit 8ed44f70782e8cd733acd3d33812d4b771c1bd9b:
    gh release create v0.1.0 --target a602187ebae72cc0e8101cc46fc116a51c9e9e39 --title foo --notes bar
  5. Run the same command but with a different commit - 8ed44f70782e8cd733acd3d33812d4b771c1bd9b:
    gh release create v0.1.0 --target 8ed44f70782e8cd733acd3d33812d4b771c1bd9b --title foo --notes bar 

Expected vs actual behavior

I expected the first gh release create command to succeed and create a release. Instead it complained about getting 404 when trying to access https://api.github.com/repos/aeon-felis/test-with-bevy-yoetz/releases - a URL that I'm able to access myself and that it was able to access just fine when I tried with a different commit.

Logs

Paste the activity from your command line. Redact if needed.

$ # Uploading a version with a commit hash that doesn't work
$ GH_DEBUG=api gh release create v0.1.0 --target a602187ebae72cc0e8101cc46fc116a51c9e9e39 --title foo --notes bar
[git remote -v]
[git config --get-regexp ^remote\..*\.gh-resolved$]
[git tag --list v0.1.0 --format=%(contents)]
[git tag --list v0.1.0 --format=%(contents:signature)]
* Request at 2024-10-17 01:33:46.735208987 +0300 IDT m=+0.055297086
* Request to https://api.github.com/repos/aeon-felis/test-with-bevy-yoetz/releases
> POST /repos/aeon-felis/test-with-bevy-yoetz/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: 142
> Content-Type: application/json; charset=utf-8
> Time-Zone: Israel
> User-Agent: GitHub CLI v2.59.0

{
  "body": "bar",
  "draft": false,
  "name": "foo",
  "prerelease": false,
  "tag_name": "v0.1.0",
  "target_commitish": "a602187ebae72cc0e8101cc46fc116a51c9e9e39"
}

< 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
< Content-Security-Policy: default-src 'none'
< Content-Type: application/json; charset=utf-8
< Date: Wed, 16 Oct 2024 22:36:00 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-Media-Type: github.v3; param=merge-info-preview.nebula-preview; format=json
< X-Github-Request-Id: D8FE:3E6E91:207FC:2E39B:67103FD0
< X-Oauth-Client-Id: 178c6fc778ccc68e1d6a
< X-Oauth-Scopes: admin:public_key, gist, read:org, repo
< X-Ratelimit-Limit: 5000
< X-Ratelimit-Remaining: 4930
< X-Ratelimit-Reset: 1729118813
< X-Ratelimit-Resource: core
< X-Ratelimit-Used: 70
< X-Xss-Protection: 0

{
  "message": "Not Found",
  "documentation_url": "https://docs.github.com/rest/releases/releases#create-a-release",
  "status": "404"
}

* Request took 361.999146ms
HTTP 404: Not Found (https://api.github.com/repos/aeon-felis/test-with-bevy-yoetz/releases)
$ 
$ # Verifying that that commit hash exists
$ git branch --all --contains a602187ebae72cc0e8101cc46fc116a51c9e9e39
* main
  remotes/origin/HEAD -> origin/main
  remotes/origin/main
$ 
$ # Running the same command using a different commit hash
$ GH_DEBUG=api gh release create v0.1.0 --target 8ed44f70782e8cd733acd3d33812d4b771c1bd9b --title foo --notes bar
[git remote -v]
[git config --get-regexp ^remote\..*\.gh-resolved$]
[git tag --list v0.1.0 --format=%(contents)]
[git tag --list v0.1.0 --format=%(contents:signature)]
* Request at 2024-10-17 01:34:15.778241751 +0300 IDT m=+0.055598163
* Request to https://api.github.com/repos/aeon-felis/test-with-bevy-yoetz/releases
> POST /repos/aeon-felis/test-with-bevy-yoetz/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: 142
> Content-Type: application/json; charset=utf-8
> Time-Zone: Israel
> User-Agent: GitHub CLI v2.59.0

{
  "body": "bar",
  "draft": false,
  "name": "foo",
  "prerelease": false,
  "tag_name": "v0.1.0",
  "target_commitish": "8ed44f70782e8cd733acd3d33812d4b771c1bd9b"
}

< HTTP/2.0 201 Created
< 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
< Cache-Control: private, max-age=60, s-maxage=60
< Content-Length: 1767
< Content-Security-Policy: default-src 'none'
< Content-Type: application/json; charset=utf-8
< Date: Wed, 16 Oct 2024 22:36:29 GMT
< Etag: "757f457333dcfd9b3006fa1643a24754c8426a81f90aba76f87857d6c424a3f8"
< Location: https://api.github.com/repos/aeon-felis/test-with-bevy-yoetz/releases/180334381
< Referrer-Policy: origin-when-cross-origin, strict-origin-when-cross-origin
< Server: github.com
< Strict-Transport-Security: max-age=31536000; includeSubdomains; preload
< Vary: Accept, Authorization, Cookie, X-GitHub-OTP,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-Media-Type: github.v3; param=merge-info-preview.nebula-preview; format=json
< X-Github-Request-Id: B4D8:3A3B84:20275:2DEC0:67103FED
< X-Oauth-Client-Id: 178c6fc778ccc68e1d6a
< X-Oauth-Scopes: admin:public_key, gist, read:org, repo
< X-Ratelimit-Limit: 5000
< X-Ratelimit-Remaining: 4929
< X-Ratelimit-Reset: 1729118813
< X-Ratelimit-Resource: core
< X-Ratelimit-Used: 71
< X-Xss-Protection: 0

{
  "url": "https://api.github.com/repos/aeon-felis/test-with-bevy-yoetz/releases/180334381",
  "assets_url": "https://api.github.com/repos/aeon-felis/test-with-bevy-yoetz/releases/180334381/assets",
  "upload_url": "https://uploads.github.com/repos/aeon-felis/test-with-bevy-yoetz/releases/180334381/assets{?name,label}",
  "html_url": "https://github.com/aeon-felis/test-with-bevy-yoetz/releases/tag/v0.1.0",
  "id": 180334381,
  "author": {
    "login": "idanarye",
    "id": 1149255,
    "node_id": "MDQ6VXNlcjExNDkyNTU=",
    "avatar_url": "https://avatars.githubusercontent.com/u/1149255?v=4",
    "gravatar_id": "",
    "url": "https://api.github.com/users/idanarye",
    "html_url": "https://github.com/idanarye",
    "followers_url": "https://api.github.com/users/idanarye/followers",
    "following_url": "https://api.github.com/users/idanarye/following{/other_user}",
    "gists_url": "https://api.github.com/users/idanarye/gists{/gist_id}",
    "starred_url": "https://api.github.com/users/idanarye/starred{/owner}{/repo}",
    "subscriptions_url": "https://api.github.com/users/idanarye/subscriptions",
    "organizations_url": "https://api.github.com/users/idanarye/orgs",
    "repos_url": "https://api.github.com/users/idanarye/repos",
    "events_url": "https://api.github.com/users/idanarye/events{/privacy}",
    "received_events_url": "https://api.github.com/users/idanarye/received_events",
    "type": "User",
    "site_admin": false
  },
  "node_id": "RE_kwDONBZL8M4Kv68t",
  "tag_name": "v0.1.0",
  "target_commitish": "8ed44f70782e8cd733acd3d33812d4b771c1bd9b",
  "name": "foo",
  "draft": false,
  "prerelease": false,
  "created_at": "2024-07-04T21:33:58Z",
  "published_at": "2024-10-16T22:36:29Z",
  "assets": [],
  "tarball_url": "https://api.github.com/repos/aeon-felis/test-with-bevy-yoetz/tarball/v0.1.0",
  "zipball_url": "https://api.github.com/repos/aeon-felis/test-with-bevy-yoetz/zipball/v0.1.0",
  "body": "bar"
}

* Request took 708.189761ms
https://github.com/aeon-felis/test-with-bevy-yoetz/releases/tag/v0.1.0

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workinggh-releaserelating to the gh release commandhelp wantedContributions welcomep3Affects a small number of users or is largely cosmetic

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions