refactor: Use error types from rpc-spec - #3173
Conversation
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
| namespace etl { | ||
|
|
||
| /** @brief Error codes produced by ETL source operations. Aliased from rpc::EtlError. */ | ||
| using EtlError = rpc::EtlError; |
There was a problem hiding this comment.
This makes the whole etl depend on rpcspec library, which doesn't make much sense.
I think you should make 2 cmake components in your rpc-spec, if you want to have EtlError as part of rpc-spec.
Clio's rpc layer will depend on rpc component, etl one will depend on etl
There was a problem hiding this comment.
The whole idea here was to factor ETL errors out of the RPC layer.. but turns out they are not actual ETL errors, they are RPC errors from ETL source/forwarding code - customer facing. So the cleanest fix is to actually bring them back as they were and keep them in rpc-spec without trying to call them etl::EtlError.
There was a problem hiding this comment.
Ok so after more research it looks like we can't really do this easily. ETL today is not just the part writing data but also the forwarding component that uses the "etl" error codes. I suggest we move them back into rpc-spec but call them "RpcForwarding[...]" instead. Then at a later stage we factor all forwarding code out of ETL module entirely. This will allow us to cleanly and honestly remove the dependency. Today though ETL will have to depend on rpc-spec simply because ETL is not just the writer part :/
| ) | ||
|
|
||
| target_link_libraries(clio_etl PUBLIC clio_data clio_util) | ||
| target_link_libraries(clio_etl PUBLIC clio_data clio_util rpcspec::rpcspec) |
There was a problem hiding this comment.
This shouldn't be like so
There was a problem hiding this comment.
Yeah i agree, ETL should not depend on RPC at all
There was a problem hiding this comment.
Having that said, for now we need to keep this because ETL is not only the writer but also the forwarding code, which uses the rpc-spec errors for forwarding failures.
There was a problem hiding this comment.
Pull request overview
Refactors Clio’s RPC error handling to rely on the shared xrpl-rpc-spec error model, keeping Clio-specific rendering helpers and updating call sites/tests to use the spec types and renamed forwarding error codes.
Changes:
- Replaced most direct usage of Clio-defined RPC error types with
<rpcspec/Errors.hpp>and updated forwarding-related errors fromEtl*toRpcForwarding*. - Updated the wire-visible “validated data” warning text to reference xrpld instead of rippled, and adjusted unit tests accordingly.
- Bumped
xrpl-rpc-specdependency to0.1.7and linkedrpcspec::rpcspecwhere needed.
Reviewed changes
Copilot reviewed 84 out of 85 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| tests/unit/web/RPCServerHandlerTests.cpp | Update warning message expectation; switch to rpcspec header include. |
| tests/unit/web/ng/RPCServerHandlerTests.cpp | Replace Clio Errors include with rpcspec include. |
| tests/unit/web/ng/impl/ErrorHandlingTests.cpp | Replace Clio Errors include with rpcspec include. |
| tests/unit/web/LoadWarningTests.cpp | Replace Clio Errors include with rpcspec include. |
| tests/unit/web/impl/ErrorHandlingTests.cpp | Replace Clio Errors include with rpcspec include. |
| tests/unit/rpc/RPCHelpersTests.cpp | Add rpcspec errors include for updated error model. |
| tests/unit/rpc/RPCEngineTests.cpp | Switch to rpcspec errors include. |
| tests/unit/rpc/handlers/VaultInfoTests.cpp | Add rpcspec errors include. |
| tests/unit/rpc/handlers/UnsubscribeTests.cpp | Add rpcspec errors include. |
| tests/unit/rpc/handlers/TxTests.cpp | Add rpcspec errors include. |
| tests/unit/rpc/handlers/TestHandlerTests.cpp | Add rpcspec errors include. |
| tests/unit/rpc/handlers/SubscribeTests.cpp | Add rpcspec errors include. |
| tests/unit/rpc/handlers/ServerInfoTests.cpp | Add rpcspec errors include; update forwarding error expectations. |
| tests/unit/rpc/handlers/LedgerTests.cpp | Add rpcspec errors include. |
| tests/unit/rpc/handlers/LedgerEntryTests.cpp | Add rpcspec errors include. |
| tests/unit/rpc/handlers/LedgerDataTests.cpp | Add rpcspec errors include. |
| tests/unit/rpc/handlers/CredentialHelpersTests.cpp | Switch to rpcspec errors include. |
| tests/unit/rpc/handlers/AccountOffersTests.cpp | Add rpcspec errors include. |
| tests/unit/rpc/handlers/AccountLinesTests.cpp | Add rpcspec errors include. |
| tests/unit/rpc/handlers/AccountInfoTests.cpp | Add rpcspec errors include. |
| tests/unit/rpc/handlers/AccountCurrenciesTests.cpp | Add rpcspec errors include. |
| tests/unit/rpc/ForwardingProxyTests.cpp | Switch to rpcspec errors include; update forwarding error expectations. |
| tests/unit/rpc/ErrorTests.cpp | Add rpcspec errors include; update warning text and forwarding error codes. |
| tests/unit/rpc/common/TypesTests.cpp | Drop direct Clio Errors include (Types already pulls it in). |
| tests/unit/rpc/common/SpecsTests.cpp | Switch to rpcspec errors include. |
| tests/unit/rpc/common/CheckersTests.cpp | Switch to rpcspec errors include. |
| tests/unit/rpc/BaseTests.cpp | Switch to rpcspec errors include. |
| tests/unit/etl/SourceImplTests.cpp | Switch to rpcspec errors include. |
| tests/unit/etl/LoadBalancerTests.cpp | Switch to rpcspec errors include; update forwarding error expectations. |
| tests/unit/etl/ForwardingSourceTests.cpp | Switch to rpcspec errors include; update forwarding error expectations. |
| tests/unit/etl/ETLStateTests.cpp | Switch to rpcspec errors include; update forwarding error expectations. |
| tests/unit/app/WebHandlersTests.cpp | Switch to rpcspec errors include. |
| tests/common/util/MockSource.hpp | Switch to rpcspec errors include. |
| src/web/ng/impl/ErrorHandling.cpp | Update forwarding error enum names; include rpcspec errors. |
| src/web/impl/ErrorHandling.hpp | Update forwarding error enum names. |
| src/web/CMakeLists.txt | Link rpcspec library into web target. |
| src/rpc/RPCHelpers.cpp | Switch to rpcspec errors include. |
| src/rpc/handlers/VaultInfo.cpp | Switch to rpcspec errors include. |
| src/rpc/handlers/Unsubscribe.cpp | Switch to rpcspec errors include. |
| src/rpc/handlers/TransactionEntry.cpp | Switch to rpcspec errors include. |
| src/rpc/handlers/Subscribe.cpp | Switch to rpcspec errors include. |
| src/rpc/handlers/NoRippleCheck.cpp | Switch to rpcspec errors include. |
| src/rpc/handlers/NFTsByIssuer.cpp | Switch to rpcspec errors include. |
| src/rpc/handlers/NFTOffersCommon.cpp | Switch to rpcspec errors include. |
| src/rpc/handlers/NFTInfo.cpp | Switch to rpcspec errors include. |
| src/rpc/handlers/NFTHistory.cpp | Switch to rpcspec errors include. |
| src/rpc/handlers/MPTokenIssuanceHistory.cpp | Switch to rpcspec errors include. |
| src/rpc/handlers/MPTHolders.cpp | Switch to rpcspec errors include. |
| src/rpc/handlers/LedgerIndex.cpp | Switch to rpcspec errors include. |
| src/rpc/handlers/LedgerEntry.cpp | Switch to rpcspec errors include. |
| src/rpc/handlers/LedgerData.cpp | Switch to rpcspec errors include. |
| src/rpc/handlers/GetAggregatePrice.cpp | Remove Clio Errors include (no longer needed). |
| src/rpc/handlers/GatewayBalances.cpp | Switch to rpcspec errors include. |
| src/rpc/handlers/Feature.cpp | Switch to rpcspec errors include. |
| src/rpc/handlers/DepositAuthorized.cpp | Switch to rpcspec errors include. |
| src/rpc/handlers/AMMInfo.cpp | Switch to rpcspec errors include. |
| src/rpc/handlers/AccountTx.cpp | Switch to rpcspec errors include. |
| src/rpc/handlers/AccountOffers.cpp | Switch to rpcspec errors include. |
| src/rpc/handlers/AccountObjects.cpp | Switch to rpcspec errors include. |
| src/rpc/handlers/AccountNFTs.cpp | Switch to rpcspec errors include. |
| src/rpc/handlers/AccountMPTokens.cpp | Switch to rpcspec errors include. |
| src/rpc/handlers/AccountMPTokenIssuances.cpp | Switch to rpcspec errors include. |
| src/rpc/handlers/AccountLines.cpp | Switch to rpcspec errors include. |
| src/rpc/handlers/AccountInfo.cpp | Switch to rpcspec errors include. |
| src/rpc/handlers/AccountCurrencies.cpp | Switch to rpcspec errors include. |
| src/rpc/handlers/AccountChannels.cpp | Switch to rpcspec errors include. |
| src/rpc/Factories.cpp | Switch to rpcspec errors include. |
| src/rpc/Errors.hpp | Convert to shim over rpcspec errors; keep Clio-side rendering surface. |
| src/rpc/Errors.cpp | Move remaining Clio-only error-info table; use std::to_array/ranges::find; update forwarding error names. |
| src/rpc/CredentialHelpers.cpp | Switch to rpcspec errors include. |
| src/rpc/common/Validators.cpp | Switch to rpcspec errors include. |
| src/rpc/common/Specs.hpp | Docstring tweaks referencing Status. |
| src/rpc/common/Specs.cpp | Switch to rpcspec errors include. |
| src/rpc/common/MetaProcessors.cpp | Switch to rpcspec errors include. |
| src/rpc/common/AnyHandler.hpp | Docstring tweak referencing Status. |
| src/feed/CMakeLists.txt | Link rpcspec library into feed target. |
| src/etl/Source.hpp | Switch to rpcspec errors include for forwarding error type usage. |
| src/etl/LoadBalancer.cpp | Update default forwarding error code to renamed RpcForwarding*. |
| src/etl/impl/SourceImpl.hpp | Switch to rpcspec errors include. |
| src/etl/impl/ForwardingSource.hpp | Switch to rpcspec errors include. |
| src/etl/impl/ForwardingSource.cpp | Rename forwarding error returns to RpcForwarding*. |
| src/etl/CMakeLists.txt | Link rpcspec library into etl target. |
| src/app/WebHandlers.cpp | Add rpcspec errors include. |
| conanfile.py | Bump xrpl-rpc-spec dependency to 0.1.7. |
| conan.lock | Update lockfile entry for xrpl-rpc-spec/0.1.7. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
| #include <boost/uuid/uuid.hpp> | ||
| #include <grpcpp/support/status.h> | ||
| #include <org/xrpl/rpc/v1/get_ledger.pb.h> | ||
| #include <rpcspec/Errors.hpp> |
| if (not expectedConnection) { | ||
| LOG(log_.debug()) << "Couldn't connect to rippled to forward request."; | ||
| return std::unexpected{rpc::ClioError::EtlConnectionError}; | ||
| return std::unexpected{rpc::ClioError::RpcForwardingConnectionError}; |
There was a problem hiding this comment.
Since you have ClioError, I think it would be great to make rpc-spec not have access to it, when server is rippled.
There was a problem hiding this comment.
Maybe as a final cleanup step when everything is working everywhere :)
There was a problem hiding this comment.
That's easier & better to do now, before someone (probably you 😆) accidentally start using clio codes in rpc-spec for rippled or rippled itself
There was a problem hiding this comment.
I'll make a pr for the rpc-spec repo, let's not enforce it in this PR yet to avoid having to make a new version and publish through conan-center
This is PR 3 out of many. It depends on merging #3171 first.
Moves the RPC error model into the shared spec library.
src/rpc/Errors.hppbecomes a shim over<rpcspec/Errors.hpp>, keeping only the Clio-side rendering:makeError,getErrorInfo,getEtlErrorInfo.ClioError::Etl*is carved out into a Clio-sideetl::EtlError(newsrc/etl/Errors.hpp), since ETL codes aren't an RPC-spec concern.Source::forwardToRipplednow returnsEtlErrorinstead ofClioError, which is what most of the diff is.Wire-visible change: the "clio only serves validated data" warning now says "if you want to talk to xrpld" instead of "rippled" — the string moved into rpcspec, which renamed it. 10 expectations updated in
RPCServerHandlerTests.cpp.Drive-by cleanups:
InvalidParamsErrorandAccountNotFoundError- unreferenced anywhere insrc/ortests/.std::to_array+ranges::findwith a projection.