code4romania/rezultate-vot-api

Diaspora winner map errors out with 500

Closed this issue · 2 comments

This is the error stack:

rezultatevot.api_1  | fail: Microsoft.EntityFrameworkCore.Update[10000]
rezultatevot.api_1  |       An exception occurred in the database while saving changes for context type 'ElectionResults.Core.Repositories.ApplicationDbContext'.
rezultatevot.api_1  |       Microsoft.EntityFrameworkCore.DbUpdateException: An error occurred while updating the entries. See the inner exception for details.
rezultatevot.api_1  |        ---> MySql.Data.MySqlClient.MySqlException (0x80004005): Duplicate entry '2' for key 'elections.PRIMARY'
rezultatevot.api_1  |          at MySql.Data.MySqlClient.MySqlStream.ReadPacket()
rezultatevot.api_1  |          at MySql.Data.MySqlClient.NativeDriver.GetResult(Int32& affectedRow, Int64& insertedId)
rezultatevot.api_1  |          at MySql.Data.MySqlClient.Driver.NextResult(Int32 statementId, Boolean force)
rezultatevot.api_1  |          at MySql.Data.MySqlClient.MySqlDataReader.NextResult()
rezultatevot.api_1  |          at MySql.Data.MySqlClient.MySqlCommand.ExecuteReader(CommandBehavior behavior)
rezultatevot.api_1  |          at System.Data.Common.DbCommand.ExecuteDbDataReaderAsync(CommandBehavior behavior, CancellationToken cancellationToken)
rezultatevot.api_1  |       --- End of stack trace from previous location where exception was thrown ---
rezultatevot.api_1  |          at Microsoft.EntityFrameworkCore.Storage.RelationalCommand.ExecuteReaderAsync(RelationalCommandParameterObject parameterObject, CancellationToken cancellationToken)
rezultatevot.api_1  |          at Microsoft.EntityFrameworkCore.Storage.RelationalCommand.ExecuteReaderAsync(RelationalCommandParameterObject parameterObject, CancellationToken cancellationToken)
rezultatevot.api_1  |          at Microsoft.EntityFrameworkCore.Storage.RelationalCommand.ExecuteReaderAsync(RelationalCommandParameterObject parameterObject, CancellationToken cancellationToken)
rezultatevot.api_1  |          at Microsoft.EntityFrameworkCore.Update.ReaderModificationCommandBatch.ExecuteAsync(IRelationalConnection connection, CancellationToken cancellationToken)
rezultatevot.api_1  |          --- End of inner exception stack trace ---
rezultatevot.api_1  |          at Microsoft.EntityFrameworkCore.Update.ReaderModificationCommandBatch.ExecuteAsync(IRelationalConnection connection, CancellationToken cancellationToken)
rezultatevot.api_1  |          at Microsoft.EntityFrameworkCore.Update.Internal.BatchExecutor.ExecuteAsync(IEnumerable`1 commandBatches, IRelationalConnection connection, CancellationToken cancellationToken)
rezultatevot.api_1  |          at Microsoft.EntityFrameworkCore.Update.Internal.BatchExecutor.ExecuteAsync(IEnumerable`1 commandBatches, IRelationalConnection connection, CancellationToken cancellationToken)
rezultatevot.api_1  |          at Microsoft.EntityFrameworkCore.ChangeTracking.Internal.StateManager.SaveChangesAsync(IList`1 entriesToSave, CancellationToken cancellationToken)
rezultatevot.api_1  |          at Microsoft.EntityFrameworkCore.ChangeTracking.Internal.StateManager.SaveChangesAsync(DbContext _, Boolean acceptAllChangesOnSuccess, CancellationToken cancellationToken)
rezultatevot.api_1  |          at MySql.Data.EntityFrameworkCore.Storage.Internal.MySQLExecutionStrategy.ExecuteAsync[TState,TResult](TState state, Func`4 operation, Func`4 verifySucceeded, CancellationToken cancellationToken)
rezultatevot.api_1  |          at Microsoft.EntityFrameworkCore.DbContext.SaveChangesAsync(Boolean acceptAllChangesOnSuccess, CancellationToken cancellationToken)
rezultatevot.api_1  | Microsoft.EntityFrameworkCore.DbUpdateException: An error occurred while updating the entries. See the inner exception for details.
rezultatevot.api_1  |  ---> MySql.Data.MySqlClient.MySqlException (0x80004005): Duplicate entry '2' for key 'elections.PRIMARY'
rezultatevot.api_1  |    at MySql.Data.MySqlClient.MySqlStream.ReadPacket()
rezultatevot.api_1  |    at MySql.Data.MySqlClient.NativeDriver.GetResult(Int32& affectedRow, Int64& insertedId)
rezultatevot.api_1  |    at MySql.Data.MySqlClient.Driver.NextResult(Int32 statementId, Boolean force)
rezultatevot.api_1  |    at MySql.Data.MySqlClient.MySqlDataReader.NextResult()
rezultatevot.api_1  |    at MySql.Data.MySqlClient.MySqlCommand.ExecuteReader(CommandBehavior behavior)
rezultatevot.api_1  |    at System.Data.Common.DbCommand.ExecuteDbDataReaderAsync(CommandBehavior behavior, CancellationToken cancellationToken)
rezultatevot.api_1  | --- End of stack trace from previous location where exception was thrown ---
rezultatevot.api_1  |    at Microsoft.EntityFrameworkCore.Storage.RelationalCommand.ExecuteReaderAsync(RelationalCommandParameterObject parameterObject, CancellationToken cancellationToken)
rezultatevot.api_1  |    at Microsoft.EntityFrameworkCore.Storage.RelationalCommand.ExecuteReaderAsync(RelationalCommandParameterObject parameterObject, CancellationToken cancellationToken)
rezultatevot.api_1  |    at Microsoft.EntityFrameworkCore.Storage.RelationalCommand.ExecuteReaderAsync(RelationalCommandParameterObject parameterObject, CancellationToken cancellationToken)
rezultatevot.api_1  |    at Microsoft.EntityFrameworkCore.Update.ReaderModificationCommandBatch.ExecuteAsync(IRelationalConnection connection, CancellationToken cancellationToken)
rezultatevot.api_1  |    --- End of inner exception stack trace ---
rezultatevot.api_1  |    at Microsoft.EntityFrameworkCore.Update.ReaderModificationCommandBatch.ExecuteAsync(IRelationalConnection connection, CancellationToken cancellationToken)
rezultatevot.api_1  |    at Microsoft.EntityFrameworkCore.Update.Internal.BatchExecutor.ExecuteAsync(IEnumerable`1 commandBatches, IRelationalConnection connection, CancellationToken cancellationToken)
rezultatevot.api_1  |    at Microsoft.EntityFrameworkCore.Update.Internal.BatchExecutor.ExecuteAsync(IEnumerable`1 commandBatches, IRelationalConnection connection, CancellationToken cancellationToken)
rezultatevot.api_1  |    at Microsoft.EntityFrameworkCore.ChangeTracking.Internal.StateManager.SaveChangesAsync(IList`1 entriesToSave, CancellationToken cancellationToken)
rezultatevot.api_1  |    at Microsoft.EntityFrameworkCore.ChangeTracking.Internal.StateManager.SaveChangesAsync(DbContext _, Boolean acceptAllChangesOnSuccess, CancellationToken cancellationToken)
rezultatevot.api_1  |    at MySql.Data.EntityFrameworkCore.Storage.Internal.MySQLExecutionStrategy.ExecuteAsync[TState,TResult](TState state, Func`4 operation, Func`4 verifySucceeded, CancellationToken cancellationToken)
rezultatevot.api_1  |    at Microsoft.EntityFrameworkCore.DbContext.SaveChangesAsync(Boolean acceptAllChangesOnSuccess, CancellationToken cancellationToken)
rezultatevot.api_1  | Microsoft.EntityFrameworkCore.DbUpdateException: An error occurred while updating the entries. See the inner exception for details.
rezultatevot.api_1  |  ---> MySql.Data.MySqlClient.MySqlException (0x80004005): Duplicate entry '2' for key 'elections.PRIMARY'
rezultatevot.api_1  |    at MySql.Data.MySqlClient.MySqlStream.ReadPacket()
rezultatevot.api_1  |    at MySql.Data.MySqlClient.NativeDriver.GetResult(Int32& affectedRow, Int64& insertedId)
rezultatevot.api_1  |    at MySql.Data.MySqlClient.Driver.NextResult(Int32 statementId, Boolean force)
rezultatevot.api_1  |    at MySql.Data.MySqlClient.MySqlDataReader.NextResult()
rezultatevot.api_1  |    at MySql.Data.MySqlClient.MySqlCommand.ExecuteReader(CommandBehavior behavior)
rezultatevot.api_1  |    at System.Data.Common.DbCommand.ExecuteDbDataReaderAsync(CommandBehavior behavior, CancellationToken cancellationToken)
rezultatevot.api_1  | --- End of stack trace from previous location where exception was thrown ---
rezultatevot.api_1  |    at Microsoft.EntityFrameworkCore.Storage.RelationalCommand.ExecuteReaderAsync(RelationalCommandParameterObject parameterObject, CancellationToken cancellationToken)
rezultatevot.api_1  |    at Microsoft.EntityFrameworkCore.Storage.RelationalCommand.ExecuteReaderAsync(RelationalCommandParameterObject parameterObject, CancellationToken cancellationToken)
rezultatevot.api_1  |    at Microsoft.EntityFrameworkCore.Storage.RelationalCommand.ExecuteReaderAsync(RelationalCommandParameterObject parameterObject, CancellationToken cancellationToken)
rezultatevot.api_1  |    at Microsoft.EntityFrameworkCore.Update.ReaderModificationCommandBatch.ExecuteAsync(IRelationalConnection connection, CancellationToken cancellationToken)
rezultatevot.api_1  |    --- End of inner exception stack trace ---
rezultatevot.api_1  |    at Microsoft.EntityFrameworkCore.Update.ReaderModificationCommandBatch.ExecuteAsync(IRelationalConnection connection, CancellationToken cancellationToken)
rezultatevot.api_1  |    at Microsoft.EntityFrameworkCore.Update.Internal.BatchExecutor.ExecuteAsync(IEnumerable`1 commandBatches, IRelationalConnection connection, CancellationToken cancellationToken)
rezultatevot.api_1  |    at Microsoft.EntityFrameworkCore.Update.Internal.BatchExecutor.ExecuteAsync(IEnumerable`1 commandBatches, IRelationalConnection connection, CancellationToken cancellationToken)
rezultatevot.api_1  |    at Microsoft.EntityFrameworkCore.ChangeTracking.Internal.StateManager.SaveChangesAsync(IList`1 entriesToSave, CancellationToken cancellationToken)
rezultatevot.api_1  |    at Microsoft.EntityFrameworkCore.ChangeTracking.Internal.StateManager.SaveChangesAsync(DbContext _, Boolean acceptAllChangesOnSuccess, CancellationToken cancellationToken)
rezultatevot.api_1  |    at MySql.Data.EntityFrameworkCore.Storage.Internal.MySQLExecutionStrategy.ExecuteAsync[TState,TResult](TState state, Func`4 operation, Func`4 verifySucceeded, CancellationToken cancellationToken)
rezultatevot.api_1  |    at Microsoft.EntityFrameworkCore.DbContext.SaveChangesAsync(Boolean acceptAllChangesOnSuccess, CancellationToken cancellationToken)
rezultatevot.api_1  |    at ElectionResults.Core.Elections.WinnersAggregator.SaveWinners(List`1 winningCandidates) in /src/ElectionResults.Core/Elections/WinnersAggregator.cs:line 266
rezultatevot.api_1  |    at ElectionResults.Core.Elections.WinnersAggregator.GetCountryWinners(Int32 ballotId) in /src/ElectionResults.Core/Elections/WinnersAggregator.cs:line 180
rezultatevot.api_1  |    at ElectionResults.API.Controllers.WinnersController.GetWinnersForCountry(Int32 ballotId) in /src/ElectionResults.API/Controllers/WinnersController.cs:line 37
rezultatevot.api_1  | Exception encountered while country winners

Fixed by #92