Assignment fails with NullReferenceException

With one particular questionnaire, we are getting an error screen when clicking “New assignment” from the menu in “Survey Setup” → “Questionnaires”.

The log has a NullReferenceException afterwards, with the following trace:

hq_1        | 2021-09-16T12:14:29.323434399Z [12:14:29 ERR] Headquarters An unhandled exception has occurred while executing the request.
hq_1        | 2021-09-16T12:14:29.323466045Z System.NullReferenceException: Object reference not set to an instance of an object.
hq_1        | 2021-09-16T12:14:29.323472515Z    at WB.Core.SharedKernels.DataCollection.Implementation.Aggregates.InterviewEntities.InterviewTreeUpdater.UpdateEnablement(InterviewTreeRoster roster) in /src/Core/SharedKernels/DataCollection/DataCollection/Implementation/Aggregates/InterviewEntities/InterviewTreeUpdate
r.cs:line 129
hq_1        | 2021-09-16T12:14:29.323491200Z    at WB.Core.SharedKernels.DataCollection.Implementation.Aggregates.InterviewEntities.InterviewTreeRoster.Accept(IInterviewTreeUpdater updater) in /src/Core/SharedKernels/DataCollection/DataCollection/Implementation/Aggregates/InterviewEntities/InterviewTreeRoster.cs:line
 77
hq_1        | 2021-09-16T12:14:29.323497844Z    at WB.Core.SharedKernels.DataCollection.Implementation.Aggregates.Interview.<>c__DisplayClass192_0.<UpdateTreeWithDependentChanges>g__PlayActionForEachNodeInOrder|0(List`1 playOrder, Action`1 action) in /src/Core/SharedKernels/DataCollection/DataCollection/Implementatio
n/Aggregates/Interview.cs:line 2326
hq_1        | 2021-09-16T12:14:29.323503292Z    at WB.Core.SharedKernels.DataCollection.Implementation.Aggregates.Interview.UpdateTreeWithDependentChanges(InterviewTree changedInterviewTree, IQuestionnaire questionnaire, Identity entityIdentity, DateTimeOffset originDate, Boolean removeLinkedAnswers) in /src/Core/Sha
redKernels/DataCollection/DataCollection/Implementation/Aggregates/Interview.cs:line 2336
hq_1        | 2021-09-16T12:14:29.323507975Z    at WB.Core.SharedKernels.DataCollection.Implementation.Aggregates.Interview.CreateTemporaryInterview(CreateTemporaryInterviewCommand command) in /src/Core/SharedKernels/DataCollection/DataCollection/Implementation/Aggregates/Interview.cs:line 1144
hq_1        | 2021-09-16T12:14:29.323513626Z    at WB.Core.Infrastructure.CommandBus.Implementation.CommandExecutor.ExecuteEventSourcedCommand(ICommand command, String origin, Type aggregateType, Guid aggregateId, IEnumerable`1 validators, IEnumerable`1 preProcessors, IEnumerable`1 postProcessors, Action`2 commandHan
dler, CancellationToken cancellationToken) in /src/Core/Infrastructure/WB.Core.Infrastructure/CommandBus/Implementation/CommandExecutor.cs:line 136
hq_1        | 2021-09-16T12:14:29.323518449Z    at WB.Core.Infrastructure.CommandBus.Implementation.CommandExecutor.ExecuteCommand(ICommand command, String origin, CancellationToken cancellationToken, Guid aggregateId) in /src/Core/Infrastructure/WB.Core.Infrastructure/CommandBus/Implementation/CommandExecutor.cs:lin
e 47
hq_1        | 2021-09-16T12:14:29.323522836Z    at WB.Core.BoundedContexts.Headquarters.Implementation.UnitOfWorkInScopeExecutor.Execute(Action`1 action, String workspace) in /src/Core/BoundedContexts/Headquarters/WB.Core.BoundedContexts.Headquarters/Implementation/UnitOfWorkInScopeExecutor.cs:line 134
hq_1        | 2021-09-16T12:14:29.323527132Z    at WB.Core.GenericSubdomains.Portable.NamedLocker.RunWithLock(String name, Action body) in /src/Core/GenericSubdomains/WB.Core.GenericSubdomains.Portable/NamedLocker.cs:line 36
hq_1        | 2021-09-16T12:14:29.323531274Z    at WB.Core.Infrastructure.CommandBus.Implementation.CommandService.ExecuteImpl(ICommand command, String origin, CancellationToken cancellationToken) in /src/Core/Infrastructure/WB.Core.Infrastructure/CommandBus/Implementation/CommandService.cs:line 95
hq_1        | 2021-09-16T12:14:29.323538129Z    at WB.Core.Infrastructure.CommandBus.Implementation.CommandService.Execute(ICommand command, String origin) in /src/Core/Infrastructure/WB.Core.Infrastructure/CommandBus/Implementation/CommandService.cs:line 34
hq_1        | 2021-09-16T12:14:29.323545720Z    at WB.UI.Headquarters.Controllers.HQController.TakeNew(String id) in /src/UI/WB.UI.Headquarters.Core/Controllers/HQController.cs:line 74
hq_1        | 2021-09-16T12:14:29.323551916Z    at lambda_method1773528(Closure , Object , Object[] )
hq_1        | 2021-09-16T12:14:29.323561779Z    at Microsoft.AspNetCore.Mvc.Infrastructure.ActionMethodExecutor.SyncActionResultExecutor.Execute(IActionResultTypeMapper mapper, ObjectMethodExecutor executor, Object controller, Object[] arguments)
hq_1        | 2021-09-16T12:14:29.323566203Z    at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.InvokeActionMethodAsync()
hq_1        | 2021-09-16T12:14:29.323570359Z    at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.Next(State& next, Scope& scope, Object& state, Boolean& isCompleted)
hq_1        | 2021-09-16T12:14:29.323574797Z    at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.InvokeNextActionFilterAsync()
hq_1        | 2021-09-16T12:14:29.323578757Z --- End of stack trace from previous location ---
hq_1        | 2021-09-16T12:14:29.323583162Z    at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.Rethrow(ActionExecutedContextSealed context)
hq_1        | 2021-09-16T12:14:29.323587390Z    at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.Next(State& next, Scope& scope, Object& state, Boolean& isCompleted)
hq_1        | 2021-09-16T12:14:29.323591668Z    at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.InvokeInnerFilterAsync()
hq_1        | 2021-09-16T12:14:29.323595662Z --- End of stack trace from previous location ---
hq_1        | 2021-09-16T12:14:29.323599507Z    at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.<InvokeNextResourceFilter>g__Awaited|24_0(ResourceInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted)
hq_1        | 2021-09-16T12:14:29.323604022Z    at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.Rethrow(ResourceExecutedContextSealed context)
hq_1        | 2021-09-16T12:14:29.323607979Z    at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.Next(State& next, Scope& scope, Object& state, Boolean& isCompleted)
hq_1        | 2021-09-16T12:14:29.323612655Z    at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.InvokeFilterPipelineAsync()
hq_1        | 2021-09-16T12:14:29.323616570Z --- End of stack trace from previous location ---
hq_1        | 2021-09-16T12:14:29.323620594Z    at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.<InvokeAsync>g__Awaited|17_0(ResourceInvoker invoker, Task task, IDisposable scope)
hq_1        | 2021-09-16T12:14:29.323624783Z    at Microsoft.AspNetCore.Routing.EndpointMiddleware.<Invoke>g__AwaitRequestTask|6_0(Endpoint endpoint, Task requestTask, ILogger logger)
hq_1        | 2021-09-16T12:14:29.323628975Z    at Swashbuckle.AspNetCore.SwaggerUI.SwaggerUIMiddleware.Invoke(HttpContext httpContext)
hq_1        | 2021-09-16T12:14:29.323632914Z    at Microsoft.AspNetCore.Builder.UseMiddlewareExtensions.<>c__DisplayClass6_1.<<UseMiddlewareInterface>b__1>d.MoveNext()
hq_1        | 2021-09-16T12:14:29.323637323Z --- End of stack trace from previous location ---
hq_1        | 2021-09-16T12:14:29.323641147Z    at Microsoft.AspNetCore.ResponseCompression.ResponseCompressionMiddleware.Invoke(HttpContext context)
hq_1        | 2021-09-16T12:14:29.323645152Z    at Microsoft.AspNetCore.Session.SessionMiddleware.Invoke(HttpContext context)
hq_1        | 2021-09-16T12:14:29.323649064Z    at Microsoft.AspNetCore.Session.SessionMiddleware.Invoke(HttpContext context)
hq_1        | 2021-09-16T12:14:29.323657027Z    at Swashbuckle.AspNetCore.Swagger.SwaggerMiddleware.Invoke(HttpContext httpContext, ISwaggerProvider swaggerProvider)
hq_1        | 2021-09-16T12:14:29.323661778Z    at Microsoft.AspNetCore.Authorization.Policy.AuthorizationMiddlewareResultHandler.HandleAsync(RequestDelegate next, HttpContext context, AuthorizationPolicy policy, PolicyAuthorizationResult authorizeResult)
hq_1        | 2021-09-16T12:14:29.323666063Z    at Microsoft.AspNetCore.Authorization.AuthorizationMiddleware.Invoke(HttpContext context)
hq_1        | 2021-09-16T12:14:29.323670081Z    at WB.UI.Headquarters.Code.Workspaces.WorkspaceRedirectMiddleware.Invoke(HttpContext context) in /src/UI/WB.UI.Headquarters.Core/Code/Workspaces/WorkspaceRedirectMiddleware.cs:line 62
hq_1        | 2021-09-16T12:14:29.323674227Z    at Microsoft.AspNetCore.Authentication.AuthenticationMiddleware.Invoke(HttpContext context)
hq_1        | 2021-09-16T12:14:29.323679732Z    at Microsoft.AspNetCore.Builder.Extensions.MapMiddleware.Invoke(HttpContext context)
hq_1        | 2021-09-16T12:14:29.323683853Z    at WB.UI.Headquarters.Metrics.HeadquartersHttpMetricsMiddleware.<>c__DisplayClass5_0.<<Invoke>g__Next|0>d.MoveNext() in /src/UI/WB.UI.Headquarters.Core/Metrics/HeadquartersHttpMetricsMiddleware.cs:line 41
hq_1        | 2021-09-16T12:14:29.323688735Z --- End of stack trace from previous location ---
hq_1        | 2021-09-16T12:14:29.323695476Z    at WB.UI.Headquarters.Metrics.HeadquartersHttpMetricsMiddleware.Invoke(HttpContext context) in /src/UI/WB.UI.Headquarters.Core/Metrics/HeadquartersHttpMetricsMiddleware.cs:line 92
hq_1        | 2021-09-16T12:14:29.323702839Z    at Microsoft.AspNetCore.Diagnostics.ExceptionHandlerMiddleware.<Invoke>g__Awaited|6_0(ExceptionHandlerMiddleware middleware, HttpContext context, Task task)
hq_1        | 2021-09-16T12:14:29.327661046Z [12:14:29 ERR] Headquarters HTTP GET /nigeria/HQ/TakeNew/bedb5e476f4a47d9a2afb720b981d9ff$1 responded 500 in 171.7833 ms

This happen consistently over several workspaces.

The questionnaire ID is bedb5e47-6f4a-47d9-a2af-b720b981d9ff.

This is on 21.06.3.31513 inside a Docker container.