Skip to content

Commit

Permalink
Merge pull request #2714 from IntersectMBO/hotfix/type-mismatch-betwe…
Browse files Browse the repository at this point in the history
…en-haskell-and-sql-result

hotfix: handle type mismatch between haskell and sql result
  • Loading branch information
MSzalowski authored Jan 24, 2025
2 parents 52988d2 + b62ca9f commit 80bdb8d
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 9 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ changes.

- Fix usage of trim on missing label
- Fix blank screen when registering as a DRep [Issue 2408](https://github.com/IntersectMBO/govtool/issues/2408)
- Fix type mismatch between sql and haskell code for stake key address

### Changed

Expand Down
15 changes: 8 additions & 7 deletions govtool/backend/app/Main.hs
Original file line number Diff line number Diff line change
Expand Up @@ -144,10 +144,6 @@ startApp vvaConfig sentryService = do

exceptionHandler :: VVAConfig -> SentryService -> Maybe Request -> SomeException -> IO ()
exceptionHandler vvaConfig sentryService mRequest exception = do
print exception
-- These are not considered application errors
-- They represent the client closing the connection prematurely
-- or the timeout thread being killed by WARP
let isNotTimeoutThread x = case fromException x of
Just TimeoutThread -> False
_ -> True
Expand All @@ -160,13 +156,18 @@ exceptionHandler vvaConfig sentryService mRequest exception = do
Nothing -> True
isNotThreadKilledByTimeoutManager x =
"Thread killed by timeout manager" `notElem` lines (show x)
shouldSkipError =
isNotUserErrorMzero x = case fromException x of
Just ioe -> not ("user error (mzero)" `isInfixOf` show (ioe :: IOException))
_ -> True

isGuardException =
isNotTimeoutThread exception &&
isNotConnectionClosedByPeer exception &&
isNotClientClosedConnection exception &&
isNotThreadKilledByTimeoutManager exception
isNotThreadKilledByTimeoutManager exception &&
isNotUserErrorMzero exception

guard shouldSkipError
guard isGuardException

let env = sentryEnv vvaConfig
case mRequest of
Expand Down
2 changes: 1 addition & 1 deletion govtool/backend/sql/get-stake-key-voting-power.sql
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ Balance AS (
)
SELECT
(COALESCE(rr.amount, 0) + COALESCE(r.amount, 0) + COALESCE(b.amount, 0)) AS total_balance,
b.addr_raw
b.addr_raw::text AS stake_address
FROM
Balance b
LEFT JOIN
Expand Down
2 changes: 1 addition & 1 deletion govtool/backend/src/VVA/AdaHolder.hs
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ getStakeKeyVotingPower ::
Text ->
m Integer
getStakeKeyVotingPower stakeKey = withPool $ \conn -> do
result <- liftIO $ SQL.query @_ @(Scientific, Text) conn getVotingPowerSql (SQL.Only stakeKey)
result <- liftIO $ SQL.query @_ @(Scientific, ByteString) conn getVotingPowerSql (SQL.Only stakeKey)
case result of
[(votingPower,_)] -> return $ floor votingPower
_ -> do
Expand Down

0 comments on commit 80bdb8d

Please sign in to comment.