Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix issues with EnumerateVersionsAsync not handling 404s #353

Merged
merged 5 commits into from
Sep 15, 2022

Conversation

jpinz
Copy link
Member

@jpinz jpinz commented Sep 15, 2022

I noticed when implementing version 0.1.346 of OSSGadget that our unit tests for package versions that don't exist would fail, as
var packageVersionExistence = await projectManager.DetailedPackageVersionExistsAsync(purl); would throw an HttpRequestException where the StatusCode is HttpStatusCode.NotFound.
I would expect this case to return a PackageVersionNotFound instance of IPackageExistence instead of throwing a 404.

This PR adds:

catch (HttpRequestException ex) when (ex.StatusCode == HttpStatusCode.NotFound)
{
    Logger.Debug("Unable to enumerate versions (404): {0}", ex.Message);
    return Array.Empty<string>();
}

to each ProjectManager's implementation of EnumerateVersionsAsync.

@jpinz jpinz added the bug Something isn't working label Sep 15, 2022
@jpinz jpinz requested a review from gfs September 15, 2022 18:36
@jpinz jpinz self-assigned this Sep 15, 2022
@jpinz jpinz requested a review from pmalmsten September 15, 2022 18:36
…ked if the package existed in the detailed version existence check, it never actually checked to see if the version ever existed.
…w should print the RemovalReasons correctly, vs System.Collections.Generic.HashSet`1[Microsoft.CST.OpenSource.Model.Enums.PackageVersionRemovalReason]
@jpinz jpinz requested a review from gfs September 15, 2022 21:14
@jpinz jpinz merged commit fb2d403 into microsoft:main Sep 15, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants