Skip to content

refactor: Use error types from rpc-spec - #3173

Open
godexsoft wants to merge 14 commits into
XRPLF:developfrom
godexsoft:refactor/consteval-specs-move-errors
Open

refactor: Use error types from rpc-spec#3173
godexsoft wants to merge 14 commits into
XRPLF:developfrom
godexsoft:refactor/consteval-specs-move-errors

Conversation

@godexsoft

Copy link
Copy Markdown
Collaborator

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.hpp becomes a shim over <rpcspec/Errors.hpp>, keeping only the Clio-side rendering: makeError, getErrorInfo, getEtlErrorInfo.

ClioError::Etl* is carved out into a Clio-side etl::EtlError (new src/etl/Errors.hpp), since ETL codes aren't an RPC-spec concern. Source::forwardToRippled now returns EtlError instead of ClioError, 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:

  • Deleted InvalidParamsError and AccountNotFoundError - unreferenced anywhere in src/ or tests/.
  • Both error-info tables become std::to_array + ranges::find with a projection.

@codecov

codecov Bot commented Aug 12, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 85.71429% with 1 line in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
src/etl/impl/ForwardingSource.cpp 80.00% 1 Missing ⚠️

📢 Thoughts on this report? Let us know!

@godexsoft
godexsoft requested a review from mathbunnyru August 26, 2026 16:07
Comment thread src/etl/Errors.hpp Outdated
namespace etl {

/** @brief Error codes produced by ETL source operations. Aliased from rpc::EtlError. */
using EtlError = rpc::EtlError;

@mathbunnyru mathbunnyru Aug 26, 2026

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

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

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

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.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

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 :/

Comment thread src/etl/CMakeLists.txt
)

target_link_libraries(clio_etl PUBLIC clio_data clio_util)
target_link_libraries(clio_etl PUBLIC clio_data clio_util rpcspec::rpcspec)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

This shouldn't be like so

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Yeah i agree, ETL should not depend on RPC at all

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

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.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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 from Etl* to RpcForwarding*.
  • Updated the wire-visible “validated data” warning text to reference xrpld instead of rippled, and adjusted unit tests accordingly.
  • Bumped xrpl-rpc-spec dependency to 0.1.7 and linked rpcspec::rpcspec where 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.

Comment thread src/etl/Source.hpp
#include <boost/uuid/uuid.hpp>
#include <grpcpp/support/status.h>
#include <org/xrpl/rpc/v1/get_ledger.pb.h>
#include <rpcspec/Errors.hpp>
Comment thread src/app/WebHandlers.cpp
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};

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Since you have ClioError, I think it would be great to make rpc-spec not have access to it, when server is rippled.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Maybe as a final cleanup step when everything is working everywhere :)

@mathbunnyru mathbunnyru Aug 27, 2026

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

That's easier & better to do now, before someone (probably you 😆) accidentally start using clio codes in rpc-spec for rippled or rippled itself

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

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

Comment thread src/rpc/common/AnyHandler.hpp
Comment thread src/rpc/Errors.cpp
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.

3 participants