Skip to content

Protocol loads Owners from package sources as an enumerable type - #5605

Merged
donnie-msft merged 11 commits into
devfrom
dev-donnie-msft-ownerAuthorProtocol
Jan 30, 2024
Merged

donnie-msft merged 11 commits into
devfrom
dev-donnie-msft-ownerAuthorProtocol

Conversation

@donnie-msft

@donnie-msft donnie-msft commented Jan 23, 2024 •

Copy link
Copy Markdown
Contributor

Bug

Fixes: NuGet/Home#13186

Regression? Last working version:

Description

Read Owners collection from package sources into an enumerable type, rather than converting it to a comma-delimited string immediately upon parsing the JSON response.

There's no effective customer change in this PR, just that the enumeration is retained in Protocol types rather than only as a concatenated string. In subsequent PRs, I'll utilize this enumeration of owners for customer benefit.

Test changes:

  • Ensure a package source response that has Owners is converted into a matching enumeration.
  • Ensure a package source response without Owners returns null and doesn't affect other metadata.
  • Update EntityFrameworkSearch.json (from stale 2017 data) with latest package search metadata result response from nuget.org.
  • Update test with fluent assertions for all properties in the updated JSON.
  • Update test/NuGet.Core.Tests/NuGet.CommandLine.Xplat.Tests/PackageSearchRunnerTests.cs which was failing as it attempted to assert that the Table Output contained owners. The registration JSON does not normally contain Owner, so I updated the JSON and the test accordingly.

PR Checklist

  • PR has a meaningful title

  • PR has a linked issue.

  • Described changes

  • Tests

    • Automated tests added
    • OR
    • Test exception
    • OR
    • N/A
  • Documentation

    • Documentation PR or issue filled
    • OR
    • N/A

@donnie-msft
donnie-msft marked this pull request as ready for review January 25, 2024 01:01
@donnie-msft
donnie-msft requested a review from a team as a code owner January 25, 2024 01:01
@donnie-msft
donnie-msft force-pushed the dev-donnie-msft-ownerAuthorProtocol branch from 904a753 to f3c260e Compare January 25, 2024 01:25
@donnie-msft
donnie-msft force-pushed the dev-donnie-msft-ownerAuthorProtocol branch from f3c260e to 8560654 Compare January 25, 2024 23:26
@donnie-msft
donnie-msft requested a review from nkolev92 January 25, 2024 23:33
nkolev92
nkolev92 previously approved these changes Jan 26, 2024

@nkolev92 nkolev92 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please get reviews from others, but this looks just fine to me.

@donnie-msft
donnie-msft requested a review from zivkan January 26, 2024 23:34
@donnie-msft

Copy link
Copy Markdown
Contributor Author

This PR is blocked since Andy has feedback and appears to be unavailable for some time. My best understanding at present is that the feedback is around potential and ongoing confusion of what "Owners" means:

Customers seeing a type with both Owners and OwnersList members, one of which returns null when the other is not, is not intuitive.

I agree that NuGet's 3 meanings of "Owners" is not intuitive. Perhaps someone can suggest an alternative name that they'd approve?
If others can chime in with their feedback on this topic, along with any suggestions, please do so!

@donnie-msft

Copy link
Copy Markdown
Contributor Author

Chatted offline with Andy. Going to investigate V2 private Hosted Feeds and their behavior with Owners.

@donnie-msft donnie-msft reopened this Jan 30, 2024
@donnie-msft
donnie-msft force-pushed the dev-donnie-msft-ownerAuthorProtocol branch from 46d7c2c to 496f019 Compare January 30, 2024 03:27
@donnie-msft

Copy link
Copy Markdown
Contributor Author

I wasn't able to see Owners coming through a NuGet.Server using V2 protocol.
Andy also mentioned offline that this code is ignoring Owners, which I believe lessens his original concern.

However, I'm now exposing OwnersList for V2 metadata as a preventative / forward-compatible approach.

Local metadata is also now populating the OwnersList from the serialized Owners, so to reduce any confusion by SDK consumers.

@donnie-msft
donnie-msft requested a review from zivkan January 30, 2024 03:32
zivkan
zivkan previously approved these changes Jan 30, 2024
if (_ownersList is null)
{
_ownersList = Owners != null ? Owners.Split(',').Select(s => s.Trim()).ToList() : null;
_ownersList = Owners != null ? Owners.Split(',').Where(s => !string.IsNullOrWhiteSpace(s)).Select(s => s.Trim()).ToList() : null;

@zivkan zivkan Jan 30, 2024 •

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can have string.Split not generate the emprty elements in the first place: https://learn.microsoft.com/en-us/dotnet/api/system.string.split?view=net-8.0#system-string-split(system-char()-system-stringsplitoptions)

edit: string.split's option probably wouldn't work for the test you have, since it's not empty, just whitespace, so your code is needed to make that test pass

@donnie-msft
donnie-msft merged commit 001ea1a into dev Jan 30, 2024
@donnie-msft
donnie-msft deleted the dev-donnie-msft-ownerAuthorProtocol branch January 30, 2024 19:55
jeffkl added a commit that referenced this pull request Mar 22, 2024
jeffkl added a commit that referenced this pull request Mar 25, 2024
nkolev92 pushed a commit that referenced this pull request Mar 26, 2024
nkolev92 pushed a commit that referenced this pull request Mar 26, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Owner package metadata is an array in JSON but a string in Protocol types

3 participants