Skip to content

Commit

Permalink
Merge pull request #2836 from IntersectMBO/fix/internal-fusion-common…
Browse files Browse the repository at this point in the history
…-tail

fix(#1841): fix unhandled missing index exception
  • Loading branch information
MSzalowski authored Jan 30, 2025
2 parents 31a3821 + 5ca5bbd commit 015a8e9
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
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 displaying DRep with doNotList property as string
- Handle exception when no index is provided to /proposal/get endpoint [Issue 1841](https://github.com/IntersectMBO/govtool/issues/1841)

### Changed

Expand Down
13 changes: 8 additions & 5 deletions govtool/backend/src/VVA/API/Types.hs
Original file line number Diff line number Diff line change
Expand Up @@ -139,11 +139,14 @@ instance ToJSON GovActionId where
instance FromHttpApiData GovActionId where
parseUrlPiece t = case Text.splitOn "#" t of
[hash, rest] -> do
index <- case readMaybe $ Text.unpack rest of
Just x -> pure x
_ -> Left (Text.tail rest <> " is not a number")
hexHash <- parseUrlPiece hash
Right $ GovActionId hexHash index
if Text.null rest
then Left "Missing index in hash#index format"
else do
index <- case readMaybe $ Text.unpack rest of
Just x -> pure x
_ -> Left (rest <> " is not a number")
hexHash <- parseUrlPiece hash
Right $ GovActionId hexHash index
_ -> Left "Not a valid hash#index value"

exampleGovActionId :: Text
Expand Down

0 comments on commit 015a8e9

Please sign in to comment.