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

Error when hiding the last package #1627

Closed
fabiostawinski opened this issue Oct 4, 2013 · 4 comments
Closed

Error when hiding the last package #1627

fabiostawinski opened this issue Oct 4, 2013 · 4 comments
Assignees

Comments

@fabiostawinski
Copy link
Contributor

I was unlisting two packages.

  • I unlisted the latest one first
  • After I tried to unlist the second one and one error was raised.

I found where is the issue, it's in LuceneIndexService.cs, method public void UpdatePackage(Package package).

This code below, replaces the package by null:
if (!package.IsLatest || package.IsLatestStable)
{
// Someone passed us in a version which was e.g. just unlisted? Or just not the latest version which is what we want to index. Doesn't really matter. We'll find one to index.
package = _packageRepository.GetAll()
.Where(p => (p.IsLatest || p.IsLatestStable) && p.PackageRegistrationKey == packageRegistrationKey)
.Include(p => p.PackageRegistration)
.Include(p => p.PackageRegistration.Owners)
.Include(p => p.SupportedFrameworks)
.FirstOrDefault();
}

Then I fixed by this code:
if (!package.IsLatest || package.IsLatestStable)
{
// Someone passed us in a version which was e.g. just unlisted? Or just not the latest version which is what we want to index. Doesn't really matter. We'll find one to index.
package = _packageRepository.GetAll()
.Where(p => p.PackageRegistrationKey == packageRegistrationKey)
.Include(p => p.PackageRegistration)
.Include(p => p.PackageRegistration.Owners)
.Include(p => p.SupportedFrameworks)
.FirstOrDefault();
}

My change was in the "Where", I removed "(p.IsLatest || p.IsLatestStable) && " because for me it doesn't make sense. Now it works.

@analogrelay
Copy link
Contributor

Thanks! We can probably make the fix soon, but would you like to just submit a Pull Request? If so, we can accept it right away :).

@ghost ghost assigned analogrelay Oct 8, 2013
@TimLovellSmith
Copy link
Member

@fabiostawinski Would you like to send us a PR for this?

@analogrelay
Copy link
Contributor

Actually, I can't get an error to raise in our code. We have logic that checks in the package is null and if so, treats it as a delete, which is valid in this case since we currently only index the latest version of each package.

Closing for now, but if you have more details feel free to reopen and comment.

fabiostawinski added a commit to fabiostawinski/NuGetGallery that referenced this issue Oct 30, 2013
fabiostawinski added a commit to fabiostawinski/NuGetGallery that referenced this issue Oct 30, 2013
Fixed the Trace.Activity for the line 101. Before is was accessing a null variable.
@fabiostawinski
Copy link
Contributor Author

I submitted a PR, I tested again here and I got the issue again.

The problems wasn't exactly what I said, but the Trace.Activity which was trying to access a property of a null object. I submited the PR. Please verify.

fabiostawinski added a commit to fabiostawinski/NuGetGallery that referenced this issue Oct 30, 2013
Creating PR in dev branch

- NuGet#1703
@analogrelay analogrelay reopened this Nov 4, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants