disunity-hq / disunity

A fullstack toolchain for modding Unity games
MIT License
20 stars 4 forks source link

Updating org member's role as second owner causes 500 #34

Closed dustinlacewell closed 5 years ago

dustinlacewell commented 5 years ago

Throws duplicate key violation. We should handle this in the controller.

web_1       | fail: Microsoft.AspNetCore.Diagnostics.DeveloperExceptionPageMiddleware[1]
web_1       |       An unhandled exception has occurred while executing the request.
web_1       | Microsoft.EntityFrameworkCore.DbUpdateException: An error occurred while updating the entries. See the inner exception for details. ---> Npgsql.PostgresException: 23505: duplicate key value violates unique constraint "IX_OrgMembers_OrgId_Role"
web_1       |    at Npgsql.NpgsqlConnector.<>c__DisplayClass161_0.<<ReadMessage>g__ReadMessageLong|0>d.MoveNext()
web_1       | --- End of stack trace from previous location where exception was thrown ---
web_1       |    at Npgsql.NpgsqlConnector.<>c__DisplayClass161_0.<<ReadMessage>g__ReadMessageLong|0>d.MoveNext()
web_1       | --- End of stack trace from previous location where exception was thrown ---
web_1       |    at Npgsql.NpgsqlDataReader.NextResult(Boolean async, Boolean isConsuming)
web_1       |    at Npgsql.NpgsqlCommand.ExecuteDbDataReader(CommandBehavior behavior, Boolean async, CancellationToken cancellationToken)
web_1       |    at Microsoft.EntityFrameworkCore.Storage.Internal.RelationalCommand.ExecuteAsync(IRelationalConnection connection, DbCommandMethod executeMethod, IReadOnlyDictionary`2 parameterValues, CancellationToken cancellationToken)
web_1       |    at Microsoft.EntityFrameworkCore.Update.ReaderModificationCommandBatch.ExecuteAsync(IRelationalConnection connection, CancellationToken cancellationToken)
web_1       |    --- End of inner exception stack trace ---
web_1       |    at Microsoft.EntityFrameworkCore.Update.ReaderModificationCommandBatch.ExecuteAsync(IRelationalConnection connection, CancellationToken cancellationToken)
web_1       |    at Microsoft.EntityFrameworkCore.Update.Internal.BatchExecutor.ExecuteAsync(DbContext _, ValueTuple`2 parameters, CancellationToken cancellationToken)
web_1       |    at Npgsql.EntityFrameworkCore.PostgreSQL.Storage.Internal.NpgsqlExecutionStrategy.ExecuteAsync[TState,TResult](TState state, Func`4 operation, Func`4 verifySucceeded, CancellationToken cancellationToken)
web_1       |    at Microsoft.EntityFrameworkCore.ChangeTracking.Internal.StateManager.SaveChangesAsync(IReadOnlyList`1 entriesToSave, CancellationToken cancellationToken)
web_1       |    at Microsoft.EntityFrameworkCore.ChangeTracking.Internal.StateManager.SaveChangesAsync(Boolean acceptAllChangesOnSuccess, CancellationToken cancellationToken)
web_1       |    at Microsoft.EntityFrameworkCore.DbContext.SaveChangesAsync(Boolean acceptAllChangesOnSuccess, CancellationToken cancellationToken)
web_1       |    at EFCoreHooks.Extensions.DbContextExtensions.HookedSaveChangesAsync[TContext](TContext dbContext, Boolean acceptAllChangesOnSuccess, CancellationToken cancellationToken)
web_1       |    at Disunity.Store.Areas.API.v1.Orgs.OrgMemberController.UpdateMemberRole(OrgMemberDto membershipDto) in /app/asp/Areas/API/v1/Orgs/OrgMemberController.cs:line 143
web_1       |    at Microsoft.AspNetCore.Mvc.Internal.ActionMethodExecutor.TaskOfIActionResultExecutor.Execute(IActionResultTypeMapper mapper, ObjectMethodExecutor executor, Object controller, Object[] arguments)
web_1       |    at System.Threading.Tasks.ValueTask`1.get_Result()
web_1       |    at Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.InvokeActionMethodAsync()
web_1       |    at Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.InvokeNextActionFilterAsync()
web_1       |    at Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.Rethrow(ActionExecutedContext context)
web_1       |    at Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.Next(State& next, Scope& scope, Object& state, Boolean& isCompleted)
web_1       |    at Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.InvokeInnerFilterAsync()
web_1       |    at Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker.InvokeNextResourceFilter()
web_1       |    at Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker.Rethrow(ResourceExecutedContext context)
web_1       |    at Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker.Next(State& next, Scope& scope, Object& state, Boolean& isCompleted)
web_1       |    at Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker.InvokeFilterPipelineAsync()
web_1       |    at Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker.InvokeAsync()
web_1       |    at Microsoft.AspNetCore.Routing.EndpointMiddleware.Invoke(HttpContext httpContext)
web_1       |    at Microsoft.AspNetCore.Routing.EndpointRoutingMiddleware.Invoke(HttpContext httpContext)
web_1       |    at Disunity.Store.Middleware.DownloadRedirectMiddleware.InvokeAsync(HttpContext context, ApplicationDbContext dbContext, IStorageProvider storage) in /app/asp/Shared/Middleware/DownloadRedirectMiddleware.cs:line 48
web_1       |    at Microsoft.AspNetCore.Authentication.AuthenticationMiddleware.Invoke(HttpContext context)
web_1       |    at Microsoft.AspNetCore.StaticFiles.StaticFileMiddleware.Invoke(HttpContext context)
web_1       |    at Microsoft.AspNetCore.Diagnostics.EntityFrameworkCore.MigrationsEndPointMiddleware.Invoke(HttpContext context)
web_1       |    at Microsoft.AspNetCore.Diagnostics.EntityFrameworkCore.DatabaseErrorPageMiddleware.Invoke(HttpContext httpContext)
web_1       |    at Microsoft.AspNetCore.Diagnostics.EntityFrameworkCore.DatabaseErrorPageMiddleware.Invoke(HttpContext httpContext)
web_1       |    at Microsoft.AspNetCore.Diagnostics.DeveloperExceptionPageMiddleware.Invoke(HttpContext context)