Skip to content
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 additional API errors machine-readable. #4590

Merged
merged 17 commits into from
May 15, 2024

Conversation

paweljakubas
Copy link
Contributor

@paweljakubas paweljakubas commented May 14, 2024

This PR makes the following API errors machine-readable:

  • ApiErrorNoSuchPool
  • ApiErrorMissingWitnessesInTransaction

In addition, we adjust the integration test suite to express expectations in terms of rich error objects instead of interpolated error message strings.

Issue

ADP-3306

@paweljakubas paweljakubas self-assigned this May 14, 2024
Copy link
Member

@jonathanknowles jonathanknowles left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @paweljakubas

This looks great!

Before merging though, it's still missing a couple of things, including Swagger definitions for the new info fields, and JSON golden tests.

I've added the missing things in: #4592

paweljakubas and others added 17 commits May 15, 2024 09:09
This is necessary to avoid failures of the following type:

```
  src/Test/Aeson/Internal/GoldenSpecs.hs:77:5:
  1) Cardano.Wallet.Api.Types, JSON golden roundtrip, JSON encoding of ApiError, produces the same JSON as is found in /home/jsk/projects/input-output-hk/cardano-wallet-0/lib/unit/test/data/Cardano/Wallet/Api/ApiError.json
       uncaught exception: AesonDecodeError
       AesonDecodeError "Error in $.samples[14]: parsing Cardano.Wallet.Api.Types.Error.ApiErrorInfo(MissingWitnessesInTransaction) failed, key \"info\" not found"

  To rerun use: --match "/Cardano.Wallet.Api.Types/JSON golden roundtrip/JSON encoding of ApiError/produces the same JSON as is found in /home/jsk/projects/input-output-hk/cardano-wallet-0/lib/unit/test/data/Cardano/Wallet/Api/ApiError.json/" --seed 1949888530

Randomized with seed 1949888530
```

The above error appears because we recently added a non-optional `info`
field to the `errMissingWitnessesInTransaction` error.
@paweljakubas paweljakubas force-pushed the paweljakubas/adp-3306/use-decode-error-info branch from 72066e0 to e9cd7df Compare May 15, 2024 07:09
Copy link
Member

@jonathanknowles jonathanknowles left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! 🎆

errMsg403InvalidConstructTx =
"It looks like I've created an empty transaction that does not have \
\any payments, withdrawals, delegations, metadata nor minting. \
\Include at least one of them."
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🍾

@jonathanknowles jonathanknowles changed the title Revamp decode errors - part 1 [ADP-3306] Make additional API errors machine-readable. May 15, 2024
@paweljakubas paweljakubas merged commit bfbb5b8 into master May 15, 2024
3 checks passed
@paweljakubas paweljakubas deleted the paweljakubas/adp-3306/use-decode-error-info branch May 15, 2024 10:28
WilliamKingNoel-Bot pushed a commit that referenced this pull request May 15, 2024
… This PR makes the following API errors machine-readable: - `ApiErrorNoSuchPool` - `ApiErrorMissingWitnessesInTransaction` In addition, we adjust the integration test suite to express expectations in terms of rich error objects instead of interpolated error message strings. ### Issue ADP-3306 Source commit: bfbb5b8
github-merge-queue bot pushed a commit that referenced this pull request May 16, 2024
…4594)

This PR follows on from #4590, and:
- Extracts out witness count validation into a common function
`validateWitnessCounts`.
- Replaces `fromIntegral` with `intCastMaybe` and `fromJustNote` with a
unique and identifiable error message.
- Changes the types of fields `{expected,detected}NumberOfKeyWits` to
`Natural`.
- Changes the name of `ErrSubmitTransactionPartiallySignedOrNoSignedTx`
to `ErrSubmitTransactionMissingWitnesses`.

## Issue

ADP-3306
paweljakubas added a commit that referenced this pull request May 16, 2024
…4594)

This PR follows on from #4590, and:
- Extracts out witness count validation into a common function
`validateWitnessCounts`.
- Replaces `fromIntegral` with `intCastMaybe` and `fromJustNote` with a
unique and identifiable error message.
- Changes the types of fields `{expected,detected}NumberOfKeyWits` to
`Natural`.
- Changes the name of `ErrSubmitTransactionPartiallySignedOrNoSignedTx`
to `ErrSubmitTransactionMissingWitnesses`.

## Issue

ADP-3306
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants