Skip to content

Get-GitHubReleaseAsset only returns first 30 assets #372

Open
@pauby

Description

@pauby

Issue Details

Using Get-GitHubReleaseAsset on a release with more than 30 assets, only returns the first 30. Note that I'm using a GitHub token. I have tried this on Windows PowerShell 5.1 and PowerShell 7.2.6 on Windows.

Steps to reproduce the issue

# note that the latest as of this date is 1.22.0 which has 39 release assets (https://github.com/syncthing/syncthing/releases/tag/v1.22.0)
$> $release = Get-GitHubRelease -OwnerName syncthing -RepositoryName syncthing -Latest
$> $asset = Get-GitHubReleaseAsset -OwnerName syncthing -RepositoryName syncthing -Release $release.id
$> $asset.count
30

Verbose logs showing the problem

$>  $repoOwner = 'syncthing'
$>  $repoNamer = 'syncthing'
$>  $release = Get-GitHubRelease -OwnerName $repoOwner -RepositoryName $repoName -Latest -Verbose
VERBOSE: [0.16.1] Executing: Get-GitHubRelease -OwnerName "syncthing" -RepositoryName "syncthing" -Latest:$true -Verbose:$true
VERBOSE: Getting latest release from syncthing/syncthing
VERBOSE: Accessing [Get] https://github.com/api/repos/syncthing/syncthing/releases/latest [Timeout = 0)]
VERBOSE: GET https://github.com/api/repos/syncthing/syncthing/releases/latest with 0-byte payload
VERBOSE: received -1-byte response of content type application/json; charset=utf-8
VERBOSE: Telemetry has been disabled via configuration. Skipping reporting event [Get-GitHubRelease].

$> $asset = Get-GitHubReleaseAsset -OwnerName $repoOwner -RepositoryName $repoName -Release $release.id -Verbose
VERBOSE: [0.16.1] Executing: Get-GitHubReleaseAsset -OwnerName "syncthing" -RepositoryName "syncthing" -Release 78911291 -Verbose:$true
VERBOSE: Getting list of assets for release 78911291
VERBOSE: Accessing [Get] https://github.com/api/repos/syncthing/syncthing/releases/78911291/assets [Timeout = 0)]
VERBOSE: GET https://github.com/api/repos/syncthing/syncthing/releases/78911291/assets with 0-byte payload
VERBOSE: received -1-byte response of content type application/json; charset=utf-8
VERBOSE: Telemetry has been disabled via configuration. Skipping reporting event [Get-GitHubReleaseAsset].

Suggested solution to the issue

Is paging at play here? If so, how do I get the second page? No suggested solution.

Requested Assignment

I'm just reporting this problem, but don't want to fix it.

Operating System

OsName               : Microsoft Windows 10 Pro
OsOperatingSystemSKU : 48
OsArchitecture       : 64-bit
WindowsVersion       : 2009
WindowsBuildLabEx    : 19041.1.amd64fre.vb_release.191206-1406
OsLanguage           : en-US
OsMuiLanguages       : {en-US, en-GB}

PowerShell Version

Name                           Value
----                           -----
PSVersion                      5.1.19041.1682
PSEdition                      Desktop
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0...}
BuildVersion                   10.0.19041.1682
CLRVersion                     4.0.30319.42000
WSManStackVersion              3.0
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1

Module Version

Running: 0.16.1
Installed: 0.16.1

Activity

added
bugThis relates to a bug in the existing module.
triage neededAn issue that needs to be reviewed by a member of the team.
on Oct 10, 2022
added
in progressWork on this issue is already underway. Please don't work start new work on it.
api-repositories-releasesWork to complete the API's defined here: https://developer.github.com/v3/repos/releases/
and removed
triage neededAn issue that needs to be reviewed by a member of the team.
on Oct 10, 2022
HowardWolosky

HowardWolosky commented on Oct 10, 2022

@HowardWolosky
Contributor

Thanks for the report.

I just drafted up a fix that I've locally verified works, but I need to update some tests as well.

Get-GitHubReleaseAsset combines three different API's into a single command: returning the full list of assets, returning a single asset and downloading an asset. In order to support downloading, it uses the single-call API (Invoke-GHRestMethod):

$params = @{
'UriFragment' = $uriFragment
'Method' = 'Get'
'Description' = $description
'AcceptHeader' = $acceptHeader
'Save' = $shouldSave
'AccessToken' = $AccessToken
'TelemetryEventName' = $MyInvocation.MyCommand.Name
'TelemetryProperties' = $telemetryProperties
}
$result = Invoke-GHRestMethod @params

However, for the "full list of assets" scenario, it really needs to be using Invoke-GHRestMethodMultipleResult which will automatically take care of paging.

Draft change is here: master...HowardWolosky:PowerShellForGitHub:releaseAssetPaging

pauby

pauby commented on Oct 10, 2022

@pauby
Author

Awesome. Thanks for picking that up and troubleshooting it so quickly.

Xander-Rudolph

Xander-Rudolph commented on Jul 25, 2023

@Xander-Rudolph

Can we get a PR on this one? It's been a while and appears to have a fix:
master...HowardWolosky:PowerShellForGitHub:releaseAssetPaging

pauby

pauby commented on Jul 25, 2023

@pauby
Author

@Xander-Rudolph are you asking for me to submit a PR?

HanwhaARudolph

HanwhaARudolph commented on Jul 25, 2023

@HanwhaARudolph

@Xander-Rudolph are you asking for me to submit a PR?

Anyone who can 😁. I had to do a really janky workaround because I'm using this PowerShell module on ephemeral images.

pauby

pauby commented on Jul 26, 2023

@pauby
Author

👍 I worked around it by creating my own function that does the work I need. It's not as complete as this as I don't need all the functionality so nothing I can PR in.

AlexYurov

AlexYurov commented on Dec 29, 2023

@AlexYurov

@HowardWolosky Could you please create a pull request for your draft? I'd really like to have this fix released so that my CI works correctly

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    api-repositories-releasesWork to complete the API's defined here: https://developer.github.com/v3/repos/releases/bugThis relates to a bug in the existing module.in progressWork on this issue is already underway. Please don't work start new work on it.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      No branches or pull requests

        Participants

        @AlexYurov@Xander-Rudolph@pauby@HowardWolosky@HanwhaARudolph

        Issue actions

          Get-GitHubReleaseAsset only returns first 30 assets · Issue #372 · microsoft/PowerShellForGitHub