Skip to content

Commit

Permalink
fix(#2920): fix unhandled exception on missing proposal for vote
Browse files Browse the repository at this point in the history
  • Loading branch information
MSzalowski committed Feb 7, 2025
1 parent b96c61f commit 555f62a
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ changes.
### Fixed

- Fix calculating votes counting for governance actions
- Fix crashing backend on unhandled missing proposal from vote [Issue 2920](https://github.com/IntersectMBO/govtool/issues/2920)

### Changed

Expand Down
7 changes: 6 additions & 1 deletion govtool/backend/src/VVA/API.hs
Original file line number Diff line number Diff line change
Expand Up @@ -278,14 +278,19 @@ getVotes :: App m => HexText -> [GovernanceActionType] -> Maybe GovernanceAction
getVotes (unHexText -> dRepId) selectedTypes sortMode mSearch = do
CacheEnv {dRepGetVotesCache} <- asks vvaCache
(votes, proposals) <- cacheRequest dRepGetVotesCache dRepId $ DRep.getVotes dRepId []

let voteMap = Map.fromList $ map (\vote@Types.Vote {..} -> (voteProposalId, vote)) votes

processedProposals <- filter (isProposalSearchedFor mSearch) <$> mapSortAndFilterProposals selectedTypes sortMode proposals

return $
[ VoteResponse
{ voteResponseVote = voteToResponse (voteMap Map.! read (unpack proposalResponseId))
{ voteResponseVote = voteToResponse vote
, voteResponseProposal = proposalResponse
}
| proposalResponse@ProposalResponse{proposalResponseId} <- processedProposals
, let proposalIdInt = read (unpack proposalResponseId) :: Int
, Just vote <- [Map.lookup (toInteger proposalIdInt) voteMap]
]

drepInfo :: App m => HexText -> m DRepInfoResponse
Expand Down

0 comments on commit 555f62a

Please sign in to comment.