PowerShell / PowerShellGallery

236 stars 65 forks source link

API V2 FindPackagesById does not tell if a package has been unlisted #264

Closed gone-for-coding closed 8 months ago

gone-for-coding commented 1 year ago

Prerequisites

Steps to reproduce

Currently the FindPackagesById() API endpoint does not seem to contain information about whether a package is unlisted or not. This means, tools like renovate will suggest to update to unlisted package versions if the version number is higher (See here: https://github.com/renovatebot/renovate/discussions/25513).

The IsLatestVersion property does not solve this issue as you may want to find the newest version of an older major release which might as well be unlisted.

Example: https://www.powershellgallery.com/packages/VMware.PowerCLI/13.2.0.22651439 is an unlisted version. There is no higher version number available currently.

The API here https://www.powershellgallery.com/api/v2/FindPackagesById()?id=%27VMware.PowerCLI%27 does not contain any information that this package version is unlisted.

    <entry>
        <id>https://www.powershellgallery.com/api/v2/Packages(Id='VMware.PowerCLI',Version='13.2.0.22651439')</id>
        <category term="NuGetGallery.OData.V2FeedPackage" scheme="http://schemas.microsoft.com/ado/2007/08/dataservices/scheme" />
        <link rel="edit" href="https://www.powershellgallery.com/api/v2/Packages(Id='VMware.PowerCLI',Version='13.2.0.22651439')" />
        <link rel="self" href="https://www.powershellgallery.com/api/v2/Packages(Id='VMware.PowerCLI',Version='13.2.0.22651439')" />
        <title type="text">VMware.PowerCLI</title>
        <updated>2023-10-31T21:27:19Z</updated>
        <author>
            <name>VMware</name>
        </author>
        <content type="application/zip" src="https://www.powershellgallery.com/api/v2/package/VMware.PowerCLI/13.2.0.22651439" />
        <m:properties>
            <d:Id>VMware.PowerCLI</d:Id>
            <d:Version>13.2.0.22651439</d:Version>
            <d:NormalizedVersion>13.2.0.22651439</d:NormalizedVersion>
            <d:Authors>VMware</d:Authors>
            <d:Copyright>Copyright (c) VMware, Inc. All rights reserved.</d:Copyright>
            <d:Created m:type="Edm.DateTime">2023-10-24T07:34:16.55</d:Created>
            <d:Dependencies>VMware.VimAutomation.Sdk:[13.2.0.22643730, ):|VMware.VimAutomation.Common:[13.2.0.22643733, ):|VMware.Vim:[8.2.0.22643731, ):|VMware.VimAutomation.Core:[13.2.0.22643732, ):|VMware.VimAutomation.Srm:[12.7.0.20091290, ):|VMware.VimAutomation.License:[12.0.0.15939670, ):|VMware.VimAutomation.Vds:[13.1.0.21610933, ):|VMware.CloudServices:[13.2.0.22643735, ):|VMware.VimAutomation.Vmc:[13.2.0.22643729, ):|VMware.VimAutomation.Nsxt:[13.1.0.21606089, ):|VMware.VimAutomation.vROps:[13.1.0.21611158, ):|VMware.VimAutomation.Cis.Core:[13.2.0.22643734, ):|VMware.VimAutomation.HorizonView:[13.2.0.22643736, ):|VMware.VimAutomation.Cloud:[13.1.0.21611174, ):|VMware.DeployAutomation:[8.0.2.22643738, ):|VMware.ImageBuilder:[8.0.2.22643727, ):|VMware.VimAutomation.Storage:[13.2.0.22643728, ):|VMware.VimAutomation.StorageUtility:[1.6.0, ):|VMware.VumAutomation:[12.7.0.20091294, ):|VMware.VimAutomation.Security:[13.1.0.21606510, ):|VMware.VimAutomation.Hcx:[13.0.0.20803747, ):|VMware.VimAutomation.WorkloadManagement:[12.4.0.18627055, ):|VMware.Sdk.Runtime:[1.0.1669.22649494, ):|VMware.Sdk.vSphere:[8.0.1669.22649494, ):|VMware.PowerCLI.VCenter:[12.6.0.19600125, ):|VMware.Sdk.Nsx.Policy:[4.1.2.22644671, ):|VMware.Sdk.Srm:[8.8.0.22644664, ):|VMware.Sdk.Vr:[8.8.0.22644684, ):|VMware.Sdk.Vcf.CloudBuilder:[5.1.0.22644675, ):|VMware.Sdk.Vcf.SddcManager:[5.1.0.22644670, ):</d:Dependencies>
            <d:Description>This Windows PowerShell module contains VMware.PowerCLI</d:Description>
            <d:DownloadCount m:type="Edm.Int32">7443724</d:DownloadCount>
            <d:GalleryDetailsUrl>https://www.powershellgallery.com/packages/VMware.PowerCLI/13.2.0.22651439</d:GalleryDetailsUrl>
            <d:IconUrl>https://raw.githubusercontent.com/vmware/PowerCLI-Example-Scripts/1710f7ccbdd9fe9a3ab3f000e920fa6e8e042c63/resources/powercli-psgallery-icon.svg</d:IconUrl>
            <d:IsLatestVersion m:type="Edm.Boolean">false</d:IsLatestVersion>
            <d:IsAbsoluteLatestVersion m:type="Edm.Boolean">false</d:IsAbsoluteLatestVersion>
            <d:IsPrerelease m:type="Edm.Boolean">false</d:IsPrerelease>
            <d:Language m:null="true" />
            <d:LastUpdated m:type="Edm.DateTime">2023-10-31T21:27:19.743</d:LastUpdated>
            <d:Published m:type="Edm.DateTime">1900-01-01T00:00:00</d:Published>
            <d:PackageHash>f5NZg5JnrhAIV11/AsLx7cDBZpQ0CW9xKEZygLQZJvt+GJWa/XzvGxxtWD14Nt9F/sdHHhXV+ZySOkC4MsIUcA==</d:PackageHash>
            <d:PackageHashAlgorithm>SHA512</d:PackageHashAlgorithm>
            <d:PackageSize m:type="Edm.Int64">37431</d:PackageSize>
            <d:ProjectUrl m:null="true" />
            <d:ReportAbuseUrl>https://www.powershellgallery.com/packages/VMware.PowerCLI/13.2.0.22651439/ReportAbuse</d:ReportAbuseUrl>
            <d:ReleaseNotes m:null="true" />
            <d:RequireLicenseAcceptance m:type="Edm.Boolean">false</d:RequireLicenseAcceptance>
            <d:Summary m:null="true" />
            <d:Tags>PSModule</d:Tags>
            <d:Title m:null="true" />
            <d:VersionDownloadCount m:type="Edm.Int32">28</d:VersionDownloadCount>
            <d:MinClientVersion m:null="true" />
            <d:LastEdited m:type="Edm.DateTime">2023-10-24T07:44:34.353</d:LastEdited>
            <d:LicenseUrl m:null="true" />
            <d:LicenseNames m:null="true" />
            <d:LicenseReportUrl m:null="true" />
            <d:ItemType>Module</d:ItemType>
            <d:FileList>VMware.PowerCLI.nuspec|EULA.txt|VMware.PowerCLI.cat|VMware.PowerCLI.ps1|VMware.PowerCLI.psd1</d:FileList>
            <d:GUID>16e76051-92c2-41c7-bdc6-ba2a467a7fd3</d:GUID>
            <d:PowerShellVersion>5.1</d:PowerShellVersion>
            <d:PowerShellHostVersion m:null="true" />
            <d:DotNetFrameworkVersion>4.7.2</d:DotNetFrameworkVersion>
            <d:CLRVersion>4.0</d:CLRVersion>
            <d:ProcessorArchitecture></d:ProcessorArchitecture>
            <d:CompanyName>VMware, Inc.</d:CompanyName>
            <d:Owners>VMware</d:Owners>
        </m:properties>
    </entry>

Expected behavior

API returns the information if a package is unlisted.

Actual behavior

No such information is available. See XML above.

Error details

No response

Environment data

API V2.

Version

7.3.6

Visuals

No response

o-l-a-v commented 8 months ago

It says published 1900-01-01.

PSResourceGet filters unlisted packages by published year not present OR published year is less than or equal to 1900.

https://github.com/PowerShell/PSResourceGet/blob/abfbf4222ef9a4c170b42e9c77df801040c69937/src/code/V2ResponseUtil.cs#L59-L60

gone-for-coding commented 8 months ago

Thanks for the hint @o-l-a-v ! That sounds like a workaround but will help until there is a boolean property like IsUnlisted, which should be added IMO.

o-l-a-v commented 8 months ago

If that's how PSResourceGet does it I don't think such a boolean will be added in the API any time soon.

gone-for-coding commented 8 months ago

I guess you are right. I'll close this one, as I have a solution now and an additional field will most likely not be added.