I’m trying to delete a tenant on my Octopus Server, and every time I do, I get the error “Sequence contains no elements”. I’ve made sure that there are no variable sets for the tenant, no infrastructure, no projects, and no stored releases with the tenant, but deletion always fails. I’m currently running v2020.3.4.
Here’s the detailed exception I found in the server log:
Exception has been thrown by the target of an invocation.
System.InvalidOperationException: Sequence contains no elements
at System.Linq.ThrowHelper.ThrowNoElementsException()
at System.Linq.Enumerable.Aggregate[TSource](IEnumerable1 source, Func
3 func)
at Octopus.Server.Web.Api.ModelRestrictionMap.TenantVariableRestriction.<>c__DisplayClass10_0.g__HasPermissionWhenOwnerIsLibraryVariableSet|3(Tenant tenant) in C:\buildAgent\work\7881e50627116cb\source\Octopus.Server\Web\Api\ModelRestrictionMap\TenantVariableRestrictionDefinition.cs:line 254
at Octopus.Server.Web.Api.ModelRestrictionMap.TenantVariableRestriction.<>c__DisplayClass10_0.b__4() in C:\buildAgent\work\7881e50627116cb\source\Octopus.Server\Web\Api\ModelRestrictionMap\TenantVariableRestrictionDefinition.cs:line 233
at Octopus.Server.Web.Api.ModelRestrictionMap.TenantVariableOwnerProvider.UsingProjectOwner[T](TenantVariable variable, Func1 whenOwnerIsProject, Func
1 whenOwnerIsLibraryVariableSet) in C:\buildAgent\work\7881e50627116cb\source\Octopus.Server\Web\Api\ModelRestrictionMap\TenantVariableRestrictionDefinition.cs:line 41
at Octopus.Server.Web.Api.ModelRestrictionMap.TenantVariableRestriction.<>c__DisplayClass10_0.g__HasOtherEditPermissions|1() in C:\buildAgent\work\7881e50627116cb\source\Octopus.Server\Web\Api\ModelRestrictionMap\TenantVariableRestrictionDefinition.cs:line 231
at Octopus.Server.Web.Api.ModelRestrictionMap.TenantVariableRestriction.HasTenantEditAndVariableEdit(TenantVariable model, ISpacePartitionPrincipal principal, IOctopusQueryExecutor queryExecutor) in C:\buildAgent\work\7881e50627116cb\source\Octopus.Server\Web\Api\ModelRestrictionMap\TenantVariableRestrictionDefinition.cs:line 226
at Octopus.Server.Web.Api.ModelRestrictionMap.TenantVariableRestriction.CanDelete(TenantVariable model, ISpacePartitionPrincipal principal, IOctopusQueryExecutor queryExecutor) in C:\buildAgent\work\7881e50627116cb\source\Octopus.Server\Web\Api\ModelRestrictionMap\TenantVariableRestrictionDefinition.cs:line 211
at Octopus.Server.Web.Infrastructure.Security.AccessChecker1.<>c__DisplayClass12_0.<CanDelete>b__2(ISpacePartitionPrincipal spacePrincipal, IOctopusQueryExecutor scopedQueryExecutor) in C:\buildAgent\work\7881e50627116cb\source\Octopus.Server\Web\Infrastructure\Security\AccessChecker.cs:line 151 at Octopus.Server.Web.Infrastructure.Security.AccessChecker
1.<>c__DisplayClass12_0.b__0() in C:\buildAgent\work\7881e50627116cb\source\Octopus.Server\Web\Infrastructure\Security\AccessChecker.cs:line 150
at Octopus.Server.Web.Infrastructure.Security.AccessChecker1.CanDelete(TModel model) in C:\buildAgent\work\7881e50627116cb\source\Octopus.Server\Web\Infrastructure\Security\AccessChecker.cs:line 147 at Octopus.Server.Web.Infrastructure.Security.DocumentRestrictions.AccessCheckerResolver.AccessCheckerTypeAdapter
2.CanDelete(TDocument model) in C:\buildAgent\work\7881e50627116cb\source\Octopus.Server\Web\Infrastructure\Security\DocumentRestrictions\AccessCheckerResolver.cs:line 132
at Octopus.Core.Security.Permissions.AccessCheckerExtensions.AssertCanDelete[TModel](IAccessChecker1 accessChecker, TModel model) in C:\buildAgent\work\7881e50627116cb\source\Octopus.Core\Security\Permissions\IAccessChecker.cs:line 38 at Octopus.Core.Persistence.Indexes.DeleteCommand.DeleteRecursive[TDocument](Func
2 getExecutor, TDocument document, ReferenceCollection seenBefore, Boolean unrestricted) in C:\buildAgent\work\7881e50627116cb\source\Octopus.Core\Persistence\Indexes\DeleteCommand.cs:line 50