ArgumentException in Authorisation Subsystem

I found following error during the analysis of the production log:

2021-08-13 11:53:24,954 [117] ERROR Microsoft.AspNetCore.Diagnostics.ExceptionHandlerMiddleware [(null)] <NOT AVAILABLE> - An unhandled exception has occurred while executing the request.
System.ArgumentException: Item has already been added. Key in dictionary: 'ProfileCacheByName'  Key being added: 'ProfileCacheByName'
   at System.Collections.Hashtable.Insert(Object key, Object nvalue, Boolean add)
   at Origam.Security.AbstractProfileProvider.GetCacheByName() in D:\a\1\s\origam-source\Origam.Security\AbstractProfileProvider.cs:line 129
   at Origam.Security.OrigamProfileProvider.GetProfile(String userName) in D:\a\1\s\origam-source\Origam.Security\OrigamProfileProvider.cs:line 128
   at Origam.DA.Service.AbstractSqlDataService.LoadDataSet(DataStructureQuery query, IPrincipal principal, DataSet dataset, String transactionId) in D:\a\1\s\origam-source\Origam.DA.Service\AbstractSqlDataService.cs:line 294
   at Origam.DA.Service.AbstractSqlDataService.LoadDataSet(DataStructureQuery dataStructureQuery, IPrincipal principal, String transactionId) in D:\a\1\s\origam-source\Origam.DA.Service\AbstractSqlDataService.cs:line 284
   at Origam.Workflow.DataServiceAgent.LoadData(DataStructureQuery query, DataSet data) in D:\a\1\s\origam-source\Origam.Workflow\Service Agents\DataServiceAgent.cs:line 140
   at Origam.Workflow.DataServiceAgent.Run() in D:\a\1\s\origam-source\Origam.Workflow\Service Agents\DataServiceAgent.cs:line 608
   at Origam.Workbench.Services.CoreServices.DataService.LoadData(Guid dataStructureId, Guid methodId, Guid defaultSetId, Guid sortSetId, String transactionId, QueryParameterCollection parameters, DataSet currentData, String entity, String columnName) in D:\a\1\s\origam-source\Origam.Workbench.Services\CoreServices\DataService.cs:line 186
   at Origam.ServerCore.Authorization.PersistedGrantStore.RemoveAllAsync(String subjectId, String clientId) in D:\a\1\s\origam-source\Origam.ServerCore\Authorization\PersistedGrantStore.cs:line 139
   at Origam.ServerCore.IdentityServerGui.Account.AccountController.Logout(LogoutInputModel model) in D:\a\1\s\origam-source\Origam.ServerCore\IdentityServerGui\Account\AccountController.cs:line 577
   at Origam.ServerCore.IdentityServerGui.Account.AccountController.Logout(String logoutId) in D:\a\1\s\origam-source\Origam.ServerCore\IdentityServerGui\Account\AccountController.cs:line 539
   at Microsoft.AspNetCore.Mvc.Infrastructure.ActionMethodExecutor.TaskOfIActionResultExecutor.Execute(IActionResultTypeMapper mapper, ObjectMethodExecutor executor, Object controller, Object[] arguments)
   at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.<InvokeActionMethodAsync>g__Logged|12_1(ControllerActionInvoker invoker)
   at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.<InvokeNextActionFilterAsync>g__Awaited|10_0(ControllerActionInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted)
   at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.Rethrow(ActionExecutedContextSealed context)
   at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.Next(State& next, Scope& scope, Object& state, Boolean& isCompleted)
   at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.InvokeInnerFilterAsync()
--- End of stack trace from previous location where exception was thrown ---
   at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.<InvokeNextResourceFilter>g__Awaited|24_0(ResourceInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted)
   at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.Rethrow(ResourceExecutedContextSealed context)
   at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.Next(State& next, Scope& scope, Object& state, Boolean& isCompleted)
   at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.InvokeFilterPipelineAsync()
--- End of stack trace from previous location where exception was thrown ---
   at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.<InvokeAsync>g__Logged|17_1(ResourceInvoker invoker)
   at Microsoft.AspNetCore.Builder.RouterMiddleware.Invoke(HttpContext httpContext)
   at Microsoft.AspNetCore.Authentication.AuthenticationMiddleware.Invoke(HttpContext context)
   at Microsoft.AspNetCore.Builder.Extensions.MapWhenMiddleware.Invoke(HttpContext context)
   at Microsoft.AspNetCore.Builder.Extensions.MapWhenMiddleware.Invoke(HttpContext context)
   at IdentityServer4.Hosting.IdentityServerMiddleware.Invoke(HttpContext context, IEndpointRouter router, IUserSession session, IEventService events) in D:\a\1\s\origam-source\IdentityServer4\Hosting\IdentityServerMiddleware.cs:line 73
   at IdentityServer4.Hosting.MutualTlsTokenEndpointMiddleware.Invoke(HttpContext context, IAuthenticationSchemeProvider schemes) in D:\a\1\s\origam-source\IdentityServer4\Hosting\MtlsTokenEndpointMiddleware.cs:line 61
   at Microsoft.AspNetCore.Authentication.AuthenticationMiddleware.Invoke(HttpContext context)
   at IdentityServer4.Hosting.BaseUrlMiddleware.Invoke(HttpContext context) in D:\a\1\s\origam-source\IdentityServer4\Hosting\BaseUrlMiddleware.cs:line 37
   at Microsoft.AspNetCore.Localization.RequestLocalizationMiddleware.Invoke(HttpContext context)
   at Microsoft.AspNetCore.Diagnostics.ExceptionHandlerMiddleware.<Invoke>g__Awaited|6_0(ExceptionHandlerMiddleware middleware, HttpContext context, Task task)

It would be great to improve the relevant code to prevent this error.

@jsusen Can we also add the fix to the 2021-1?

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.