-
Notifications
You must be signed in to change notification settings - Fork 217
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[ADP-3306] Make NoSuchWallet
error machine-readable.
#4597
[ADP-3306] Make NoSuchWallet
error machine-readable.
#4597
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for making this PR! I've left a few suggestions.
I believe the unit test failure will be fixed by: #4598.
One last request: would it be possible to fill out the PR description?
Many thanks again!
lib/integration/scenarios/Test/Integration/Scenario/API/Shelley/Transactions.hs
Outdated
Show resolved
Hide resolved
@@ -312,3 +315,10 @@ data ApiErrorNoSuchPool = ApiErrorNoSuchPool | |||
deriving (Data, Eq, Generic, Show, Typeable) | |||
deriving (FromJSON, ToJSON) via DefaultRecord ApiErrorNoSuchPool | |||
deriving anyclass NFData | |||
|
|||
data ApiErrorNoSuchWallet = ApiErrorNoSuchWallet | |||
{ walletId :: !Text |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Suggestion: does it make sense to use ApiT WalletId
here?
{ walletId :: !Text | |
{ walletId :: !(ApiT WalletId) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
trying to use pattern synonyms here -> 984bb6e
] | ||
decodeErrorInfo r `Lifted.shouldBe` | ||
(NoSuchWallet $ ApiErrorNoSuchWallet $ w ^. walletId) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For cases like this, I would suggest:
(NoSuchWallet $ ApiErrorNoSuchWallet $ w ^. walletId) | |
NoSuchWallet (ApiErrorNoSuchWallet $ w ^. walletId) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(I think hlint
highlights a series of similar cases.)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
indeed, done
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@paweljakubas hlint
is also failing for these: https://buildkite.com/cardano-foundation/cardano-wallet/builds/4956#018f8702-7a5f-465b-8b49-1b376461a17a
specifications/api/swagger.yaml
Outdated
@@ -4361,6 +4361,18 @@ x-errNoUtxosAvailable: &errNoUtxosAvailable | |||
type: string | |||
enum: ['no_utxos_available'] | |||
|
|||
x-errNoSuchWalletInitialized: &errNoSuchWalletInitialized |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Related to #4597 (comment) (above):
x-errNoSuchWalletInitialized: &errNoSuchWalletInitialized | |
x-errWalletNotInitialized: &errWalletNotInitialized |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
specifications/api/swagger.yaml
Outdated
@@ -4361,6 +4361,18 @@ x-errNoUtxosAvailable: &errNoUtxosAvailable | |||
type: string | |||
enum: ['no_utxos_available'] | |||
|
|||
x-errNoSuchWalletInitialized: &errNoSuchWalletInitialized | |||
<<: *responsesErr | |||
title: no_such_wallet_initialized |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Related to #4597 (comment) (above):
title: no_such_wallet_initialized | |
title: wallet_not_initialized |
specifications/api/swagger.yaml
Outdated
@@ -5627,6 +5645,13 @@ x-responsesErr404WalletNotFound: &responsesErr404WalletNotFound | |||
application/json: | |||
schema: *errNoSuchWallet | |||
|
|||
x-responsesErr404DbNotInitialized: &responsesErr404DbNotInitialized | |||
404: | |||
description: DB uninitialized |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
description: DB uninitialized | |
description: Wallet not yet initialized. |
NoSuchWallet
error.
NoSuchWallet
error.NoSuchWallet
error machine-readable.
9dc071b
to
984bb6e
Compare
This is necessary, as type `ApiErrorNoSuchWallet` uses a real `WalletId` instead of just `Text`.
984bb6e
to
c9a339a
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
@paweljakubas, many thanks for making this PR!
This particular test happens to use `rawRequest` instead of `request`. Whereas the `request` function attempts to decode the response into a JSON `Value`, the `rawRequest` function does not perform any decoding. This causes the subsequent `decodeErrorInfo` to fail with: ``` uncaught exception: ErrorCall decodeErrorInfo: Expected a 'ClientError', but encountered something else: Left (RawClientError "{\"code\":\"no_such_wallet\",\"info\":{\"wallet_id\":\"acab1951ad1ef5808eb9756b02d1ff85caf0e702\"},\"message\":\"I couldn't find a wallet with the given id: acab1951ad1ef5808eb9756b02d1ff85caf0e702\"}") CallStack (from HasCallStack): error, called at framework/Test/Integration/Framework/DSL.hs:742:13 in cardano-wallet-integration-2024.5.5-KhWmuWPIqBp7pTemTBE3I2-framework:Test.Integration.Framework.DSL decodeErrorInfo, called at scenarios/Test/Integration/Scenario/API/Shelley/Wallets.hs:1495:9 in cardano-wallet-integration-2024.5.5-AcHGWrd1jBGKoKhY01VJRG-scenarios:Test.Integration.Scenario.API.Shelley.Wallets ```
NoSuchWallet
to includeWalletId
.NoSuchWallet
rather thanerr403NoSuchErrorMsg
throughout integration testsIssue
ADP-3306