Skip to content

Commit b62ca9f

Browse files
committed
hotfix: handle type mismatch between haskell and sql result
1 parent 52988d2 commit b62ca9f

File tree

4 files changed

+11
-9
lines changed

4 files changed

+11
-9
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ changes.
3838

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

4243
### Changed
4344

govtool/backend/app/Main.hs

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -144,10 +144,6 @@ startApp vvaConfig sentryService = do
144144

145145
exceptionHandler :: VVAConfig -> SentryService -> Maybe Request -> SomeException -> IO ()
146146
exceptionHandler vvaConfig sentryService mRequest exception = do
147-
print exception
148-
-- These are not considered application errors
149-
-- They represent the client closing the connection prematurely
150-
-- or the timeout thread being killed by WARP
151147
let isNotTimeoutThread x = case fromException x of
152148
Just TimeoutThread -> False
153149
_ -> True
@@ -160,13 +156,18 @@ exceptionHandler vvaConfig sentryService mRequest exception = do
160156
Nothing -> True
161157
isNotThreadKilledByTimeoutManager x =
162158
"Thread killed by timeout manager" `notElem` lines (show x)
163-
shouldSkipError =
159+
isNotUserErrorMzero x = case fromException x of
160+
Just ioe -> not ("user error (mzero)" `isInfixOf` show (ioe :: IOException))
161+
_ -> True
162+
163+
isGuardException =
164164
isNotTimeoutThread exception &&
165165
isNotConnectionClosedByPeer exception &&
166166
isNotClientClosedConnection exception &&
167-
isNotThreadKilledByTimeoutManager exception
167+
isNotThreadKilledByTimeoutManager exception &&
168+
isNotUserErrorMzero exception
168169

169-
guard shouldSkipError
170+
guard isGuardException
170171

171172
let env = sentryEnv vvaConfig
172173
case mRequest of

govtool/backend/sql/get-stake-key-voting-power.sql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ Balance AS (
3030
)
3131
SELECT
3232
(COALESCE(rr.amount, 0) + COALESCE(r.amount, 0) + COALESCE(b.amount, 0)) AS total_balance,
33-
b.addr_raw
33+
b.addr_raw::text AS stake_address
3434
FROM
3535
Balance b
3636
LEFT JOIN

govtool/backend/src/VVA/AdaHolder.hs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ getStakeKeyVotingPower ::
5151
Text ->
5252
m Integer
5353
getStakeKeyVotingPower stakeKey = withPool $ \conn -> do
54-
result <- liftIO $ SQL.query @_ @(Scientific, Text) conn getVotingPowerSql (SQL.Only stakeKey)
54+
result <- liftIO $ SQL.query @_ @(Scientific, ByteString) conn getVotingPowerSql (SQL.Only stakeKey)
5555
case result of
5656
[(votingPower,_)] -> return $ floor votingPower
5757
_ -> do

0 commit comments

Comments
 (0)