Skip to content

gh release download errors confusingly when release is a draft #10797

@williammartin

Description

@williammartin

Describe the bug

Running gh release download targeting a draft release errors in a confusing manner:

➜ gh release download v0.0.2 --archive=zip
Get "": unsupported protocol scheme ""

Affected version

Please run gh version and paste the output below.

Steps to reproduce the behavior

Steps to reproduce the behavior:

  1. Create a draft release
  2. Set it to use a tag that will be created when the release is published
  3. Save it but don't publish it
  4. Use the gh release download -R org/repo <tag-from-step-2> --archive=zip
  5. Watch the GitHub CLI throw the Get "": unsupported protocol scheme "" error

This occurs because we attempt to use the zipball_url, which is unmarshaled into an empty string here:

var archiveURL = release.ZipballURL

> GET /repos/williammartin-test-org/test-repo/releases/212464261 HTTP/1.1
> Host: api.github.com
> Accept: application/vnd.github.merge-info-preview+json, application/vnd.github.nebula-preview
> Authorization: token ████████████████████
> Content-Type: application/json; charset=utf-8
> Time-Zone: Europe/Amsterdam
> User-Agent: GitHub CLI 2.68.0

...

{
  "url": "https://api.github.com/repos/williammartin-test-org/test-repo/releases/212464261",
...
  "tarball_url": null,
  "zipball_url": null,
  "body": ""
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workinggh-releaserelating to the gh release commandp3Affects 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