From a16d16a32a9842368f5b2955ce8c93c6ec0e51fc Mon Sep 17 00:00:00 2001 From: ManuelArto Date: Fri, 26 Jun 2026 15:36:56 +0200 Subject: [PATCH] fix(debug_getRawTransaction): return null instead of error for missing transaction Co-Authored-By: Claude Sonnet 4.6 --- .../Modules/DebugModuleTests.cs | 13 +++++++++---- .../Modules/DebugModule/DebugRpcModule.cs | 2 +- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/src/Nethermind/Nethermind.JsonRpc.Test/Modules/DebugModuleTests.cs b/src/Nethermind/Nethermind.JsonRpc.Test/Modules/DebugModuleTests.cs index 730bc7e6e386..6f14d9fcbd91 100644 --- a/src/Nethermind/Nethermind.JsonRpc.Test/Modules/DebugModuleTests.cs +++ b/src/Nethermind/Nethermind.JsonRpc.Test/Modules/DebugModuleTests.cs @@ -141,6 +141,15 @@ public async Task DebugGetRawTransaction_WhenTransactionExists_ReturnsTransactio Assert.That(serialized, Is.EqualTo($"{{\"jsonrpc\":\"2.0\",\"result\":\"{expected}\",\"id\":67}}")); } + [Test] + public async Task DebugGetRawTransaction_WhenTransactionNotFound_ReturnsNull() + { + _debugBridge.GetTransactionFromHash(Keccak.Zero).ReturnsNull(); + + string serialized = await SerializedRequest("debug_getRawTransaction", Keccak.Zero); + Assert.That(serialized, Is.EqualTo("{\"jsonrpc\":\"2.0\",\"result\":null,\"id\":67}")); + } + [Test] public async Task DebugGetRawReceipts_WhenReceiptsExist_ReturnsHexArray() { @@ -484,10 +493,6 @@ private static IEnumerable RawMissingCases() (Action)(b => b.GetBlock(new BlockParameter(Keccak.Zero)).ReturnsNull()), "debug_getRawBlock", (object)Keccak.Zero) { TestName = "RawBlock_ByHash" }; - yield return new TestCaseData( - (Action)(b => b.GetTransactionFromHash(Keccak.Zero).ReturnsNull()), - "debug_getRawTransaction", (object)Keccak.Zero) - { TestName = "RawTransaction" }; } private static IEnumerable RawBlockAccessListErrorCases() diff --git a/src/Nethermind/Nethermind.JsonRpc/Modules/DebugModule/DebugRpcModule.cs b/src/Nethermind/Nethermind.JsonRpc/Modules/DebugModule/DebugRpcModule.cs index 45961dba1310..dabc0399897a 100644 --- a/src/Nethermind/Nethermind.JsonRpc/Modules/DebugModule/DebugRpcModule.cs +++ b/src/Nethermind/Nethermind.JsonRpc/Modules/DebugModule/DebugRpcModule.cs @@ -517,7 +517,7 @@ public ResultWrapper> debug_getRawTransaction(Hash256 transa Transaction? transaction = debugBridge.GetTransactionFromHash(transactionHash); if (transaction is null) { - return ResultWrapper>.Fail($"Transaction {transactionHash} was not found", ErrorCodes.ResourceNotFound); + return ResultWrapper>.Success(null); } RlpBehaviors encodingSettings = RlpBehaviors.SkipTypedWrapping | (transaction.IsInMempoolForm() ? RlpBehaviors.InMempoolForm : RlpBehaviors.None);