Remove unreachable error constructors#1211
Conversation
None of these were produced anywhere in the repo — only defined,
pretty-printed, and listed in golden fixtures.
Removed:
- TransactionValidityError (entire type, both constructors:
TransactionValidityIntervalError, TransactionValidityCostModelError)
- TxFeeEstimationTransactionTranslationError, the TxFeeEstimationError
constructor that wrapped TransactionValidityError
- TxBodyErrorByronEraNotSupported, TxBodyErrorMissingParamMinUTxO, and
TxBodyErrorNonAdaAssetsUnbalanced from the legacy
Cardano.Api.Tx.Internal.Fee.TxBodyErrorAutoBalance
- TxBodyErrorNonAdaAssetsUnbalanced from the experimental
Cardano.Api.Experimental.Tx.Internal.Fee.TxBodyErrorAutoBalance
The corresponding test_TransactionValidityError golden test, the three
dead TxBodyErrorAutoBalance fixture entries, and their expected .txt
files are dropped too. The Ouroboros.Consensus.HardFork.History import
in Fee.hs becomes unused and is removed.
There was a problem hiding this comment.
Pull request overview
This PR removes six error constructors from cardano-api's transaction/fee error types that have no producers anywhere in the repo (only definition, pretty-printing, and golden fixtures referenced them). It continues the cleanup pattern from PR #1180. Because both constructors of TransactionValidityError are dead, the entire GADT is dropped, which in turn makes the wrapping TxFeeEstimationTransactionTranslationError unreachable and is also removed.
Changes:
- Drop
TransactionValidityError(and its export fromCardano.Api.Tx/Fee), the wrappingTxFeeEstimationTransactionTranslationError, and four deadTxBodyErrorAutoBalanceconstructors across legacy and experimental modules. - Remove the corresponding
test_TransactionValidityErrorgolden test, three deadTxBodyErrorAutoBalancefixture entries, and their.txtfiles. - Drop the now-unused
Ouroboros.Consensus.HardFork.Historyimport inFee.hsand add abreakingHerald changelog fragment.
Reviewed changes
Copilot reviewed 9 out of 9 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| cardano-api/src/Cardano/Api/Tx/Internal/Fee.hs | Removes TransactionValidityError GADT, TxFeeEstimationTransactionTranslationError, three dead TxBodyErrorAutoBalance constructors, and the now-unused Consensus import. |
| cardano-api/src/Cardano/Api/Tx.hs | Drops the TransactionValidityError(..) re-export. |
| cardano-api/src/Cardano/Api/Experimental/Tx/Internal/Fee.hs | Removes TxBodyErrorNonAdaAssetsUnbalanced and its pretty-printer. |
| cardano-api/test/cardano-api-golden/Test/Golden/ErrorsSpec.hs | Drops test_TransactionValidityError and the three dead TxBodyErrorAutoBalance fixture entries. |
| cardano-api/test/cardano-api-golden/files/errors/.../TxBodyErrorByronEraNotSupported.txt | Removes the dead golden fixture file. |
| cardano-api/test/cardano-api-golden/files/errors/.../TxBodyErrorMissingParamMinUTxO.txt | Removes the dead golden fixture file. |
| cardano-api/test/cardano-api-golden/files/errors/.../TxBodyErrorNonAdaAssetsUnbalanced.txt | Removes the dead golden fixture file. |
| cardano-api/test/cardano-api-golden/files/errors/.../TransactionValidityCostModelError.txt | Removes the dead golden fixture file. |
| .changes/20260515_cardano_api_remove_unreachable_error_constructors.yml | Adds a Herald changelog fragment correctly classified as breaking. |
palas
left a comment
There was a problem hiding this comment.
Solid PR 👍
Only errors and golden tests over those errors were deleted, and it compiles, so I cannot think of any issue with that
Changelog
Context
Continuing the pattern of PR #1180 / commit 926606fdd ("Remove unused
TxBodyProtocolParamsConversionErrorconstructor"). An audit of theTxBodyError/TxBodyErrorAutoBalance/TxFeeEstimationError/TransactionValidityErrortypes found six error constructors with no production producers — only the data declaration, theprettyErrorpattern match, and golden fixtures referenced them.Construction-site search (across
cardano-api/src,cardano-api/test,cardano-api/gen) found zero call sites of the formLeft X …/X …/first X …/\$ X …for any of the constructors removed here.Since both
TransactionValidityErrorconstructors are dead, the whole GADT is removed, which in turn makesTxFeeEstimationTransactionTranslationErrorunreachable.How to trust this PR
Sanity-check that no producer remains for any removed constructor:
git grep -nE 'TransactionValidity(Interval|CostModel)Error|TxFeeEstimationTransactionTranslationError|TxBodyErrorByronEraNotSupported|TxBodyErrorMissingParamMinUTxO|TxBodyErrorNonAdaAssetsUnbalanced'After this PR the only matches should be in
CHANGELOG.md/ release notes.Checklist
.changes/(added in a follow-up commit once PR number is known, matching the project's existing pattern)