System.NullReferenceException Uploading using and deleting packages

HI I’m having issues related to a package I have uploaded to octopus. I can’t delete the package or add any new packages any project that tries to use the package I am referencing gets an error when I try and create a release. I have tried to delete the package from the file system and restart octopus and do reindexes but the package is not removed. The error you get is below:

I get this error when trying to re index the packages:

== Warning: Remove old packages ==
08:09:59 Info | Removing deleted packages.
08:09:59 Info | Could not find the package PackageName on the file system at D:\Octopus\Packages\Spaces-1\feeds-builtin\PackageName\PackageName.9.3.0.zip, it will be removed from the package repository.
08:09:59 Verbose | Deleting package PackageName.9.3.0.zip.

Unhandled error on request: https://octopus.justaftermidnight.io/api/Spaces-1/packages/raw?replace=true b6ef1c159f2540c1b4ab684ccbef98c3 by : Object reference not set to an instance of an object.
System.NullReferenceException: Object reference not set to an instance of an object.
at Octopus.Server.Web.Api.ModelRestrictionMap.PackageUsages.<>c__DisplayClass1_0.b__2(PackageReference p) in C:\buildAgent\work\abb2fbfce959a439\source\Octopus.Server\Web\Api\ModelRestrictionMap\PackageUsages.cs:line 30
at System.Linq.Enumerable.Any[TSource](IEnumerable1 source, Func2 predicate)
at System.Linq.Enumerable.Any[TSource](IEnumerable1 source, Func2 predicate)
at System.Linq.Enumerable.Any[TSource](IEnumerable1 source, Func2 predicate)
at System.Linq.Enumerable.WhereSelectListIterator2.MoveNext() at System.Linq.Enumerable.<DistinctIterator>d__641.MoveNext()
at System.Linq.Buffer1..ctor(IEnumerable1 source)
at System.Linq.Enumerable.ToArray[TSource](IEnumerable1 source) at Octopus.Server.Web.Api.ModelRestrictionMap.PackageRestriction.CheckPermissionInProjects(IndexedPackage model, ISpacePartitionPrincipal principal, IOctopusQueryExecutor queryExecutor, Permission permissionToCheck) at Octopus.Server.Web.Infrastructure.Security.DocumentRestrictions.CompositeAndRestriction2.CombineWithAnd(Func2 check) in C:\buildAgent\work\abb2fbfce959a439\source\Octopus.Server\Web\Infrastructure\Security\DocumentRestrictions\CompositeAndRestriction.cs:line 44 at Octopus.Server.Web.Infrastructure.Security.DocumentRestrictions.CompositeAndRestriction2.CombineWithAnd(Func2 check) in C:\buildAgent\work\abb2fbfce959a439\source\Octopus.Server\Web\Infrastructure\Security\DocumentRestrictions\CompositeAndRestriction.cs:line 44 at Octopus.Server.Web.Infrastructure.Security.AccessChecker1.<>c__DisplayClass13_0.b__0() in C:\buildAgent\work\abb2fbfce959a439\source\Octopus.Server\Web\Infrastructure\Security\AccessChecker.cs:line 161
at Octopus.Server.Web.Infrastructure.Security.AccessChecker1.CanDelete(TModel model) in C:\buildAgent\work\abb2fbfce959a439\source\Octopus.Server\Web\Infrastructure\Security\AccessChecker.cs:line 158 at Octopus.Core.Security.Permissions.AccessCheckerExtensions.AssertCanDelete[TModel](IAccessChecker1 accessChecker, TModel model) in C:\buildAgent\work\abb2fbfce959a439\source\Octopus.Core\Security\Permissions\IAccessChecker.cs:line 39
at Octopus.Server.Web.Infrastructure.OctopusQueryExecutor.Delete[TDocument](TDocument instance, Nullable`1 commandTimeout) in C:\buildAgent\work\abb2fbfce959a439\source\Octopus.Server\Web\Infrastructure\OctopusQueryExecutor.cs:line 236
at Octopus.Core.BuiltInFeed.BuiltInPackageIndex.DeletePackage(IndexedPackage package) in C:\buildAgent\work\abb2fbfce959a439\source\Octopus.Core\BuiltInFeed\BuiltInPackageIndex.cs:line 35

Hi Richard,

Thanks for getting in touch!

You may need to manually remove the package entry from the database to resolve this. Grab a backup of the database before making any changes, and then check the dbo.NuGetPackage table for the offending entry and delete it.

Out of curiosity, is this a new package name or just the latest version of a package with no real difference other than the version number?

Regards,
Paul