From 00761dbb674e091732bcce7e431a3048f7f6d8e7 Mon Sep 17 00:00:00 2001 From: Mayukha Vadari Date: Mon, 6 Apr 2026 18:15:16 -0400 Subject: [PATCH] fix: Minor RPC fixes (#6730) --- API-CHANGELOG.md | 2 ++ src/test/rpc/Roles_test.cpp | 1 + src/xrpld/rpc/handlers/ledger/LedgerDiff.cpp | 2 +- src/xrpld/rpc/handlers/utility/Ping.cpp | 4 +++- 4 files changed, 7 insertions(+), 2 deletions(-) diff --git a/API-CHANGELOG.md b/API-CHANGELOG.md index 64b61c2024..8e7fb2e4d4 100644 --- a/API-CHANGELOG.md +++ b/API-CHANGELOG.md @@ -38,6 +38,8 @@ This section contains changes targeting a future version. ### Bugfixes - Peer Crawler: The `port` field in `overlay.active[]` now consistently returns an integer instead of a string for outbound peers. [#6318](https://github.com/XRPLF/rippled/pull/6318) +- `ping`: The `ip` field is no longer returned as an empty string for proxied connections without a forwarded-for header. It is now omitted, consistent with the behavior for identified connections. [#6730](https://github.com/XRPLF/rippled/pull/6730) +- gRPC `GetLedgerDiff`: Fixed error message that incorrectly said "base ledger not validated" when the desired ledger was not validated. [#6730](https://github.com/XRPLF/rippled/pull/6730) ## XRP Ledger server version 3.1.0 diff --git a/src/test/rpc/Roles_test.cpp b/src/test/rpc/Roles_test.cpp index e3d90a9c56..314d0972d2 100644 --- a/src/test/rpc/Roles_test.cpp +++ b/src/test/rpc/Roles_test.cpp @@ -43,6 +43,7 @@ class Roles_test : public beast::unit_test::suite Env env{*this, envconfig(secure_gateway)}; BEAST_EXPECT(env.rpc("ping")["result"]["role"] == "proxied"); + BEAST_EXPECT(!env.rpc("ping")["result"].isMember("ip")); auto wsRes = makeWSClient(env.app().config())->invoke("ping")["result"]; BEAST_EXPECT(!wsRes.isMember("unlimited") || !wsRes["unlimited"].asBool()); diff --git a/src/xrpld/rpc/handlers/ledger/LedgerDiff.cpp b/src/xrpld/rpc/handlers/ledger/LedgerDiff.cpp index 56a4d97b94..97c4efcc7a 100644 --- a/src/xrpld/rpc/handlers/ledger/LedgerDiff.cpp +++ b/src/xrpld/rpc/handlers/ledger/LedgerDiff.cpp @@ -36,7 +36,7 @@ doLedgerDiffGrpc(RPC::GRPCContext& con std::dynamic_pointer_cast(desiredLedgerRv); if (!desiredLedger) { - grpc::Status const errorStatus{grpc::StatusCode::NOT_FOUND, "base ledger not validated"}; + grpc::Status const errorStatus{grpc::StatusCode::NOT_FOUND, "desired ledger not validated"}; return {response, errorStatus}; } diff --git a/src/xrpld/rpc/handlers/utility/Ping.cpp b/src/xrpld/rpc/handlers/utility/Ping.cpp index 4e9b18c4c9..695d90b964 100644 --- a/src/xrpld/rpc/handlers/utility/Ping.cpp +++ b/src/xrpld/rpc/handlers/utility/Ping.cpp @@ -27,7 +27,9 @@ doPing(RPC::JsonContext& context) break; case Role::PROXY: ret[jss::role] = "proxied"; - ret[jss::ip] = std::string{context.headers.forwardedFor}; + if (!context.headers.forwardedFor.empty()) + ret[jss::ip] = std::string{context.headers.forwardedFor}; + break; default:; }