From e496b49d483a676de9ce7a6bcefb8b1f1e329e89 Mon Sep 17 00:00:00 2001 From: Antoine du Hamel Date: Tue, 25 Jun 2024 19:24:28 +0200 Subject: [PATCH] fix(core): do not crash the vote count in case of invalid ballot --- packages/core/src/vote.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/core/src/vote.ts b/packages/core/src/vote.ts index e372f89..2407332 100644 --- a/packages/core/src/vote.ts +++ b/packages/core/src/vote.ts @@ -143,7 +143,7 @@ export default class Vote { } public addBallotFile(ballotData: BallotFileFormat, author?: string): Ballot { - if (checkBallot(ballotData, this.voteFileData, author)) { + if (ballotData && checkBallot(ballotData, this.voteFileData, author)) { const preferences: Map = new Map( ballotData.preferences.map((element) => [element.title, element.score]) ); @@ -154,7 +154,7 @@ export default class Vote { this.addBallot(ballot); return ballot; } else { - console.warn("Invalid Ballot"); + console.warn("Invalid Ballot", author); } return null; }