debug_getRawTransaction: return null instead of error for missing transaction#12151
Conversation
…g transaction Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
|
Claude finished @manusw7's task in 1m 32s —— View job PR Review:
|
svlachakis
left a comment
There was a problem hiding this comment.
This is non sense but if that's what the spec says let's do it. @manusw7 do you have spec reference link for that?
First thing to mention, our own The spec reference chcked is execution-apis#transaction.yaml, where all For Decide if we want to merge to have consistent behavior within the codebase, or we should wait for the above PRs first |
|
@manusw7 why you did it makes sense, overall it doesn't make sense to return nulls instead of user friendly error messages |
Description
DebugRpcModule.debug_getRawTransactionwas returning a JSON-RPC error (-32001 ResourceNotFound) when a transaction hash is not found. The correct behaviour — consistent with the execution-apis spec and with Nethermind's owneth_getRawTransactionByHashimplementation — is to return a successful response with anullresult.Steps to Reproduce
Call
debug_getRawTransactionwith a hash that does not exist on the node:{"jsonrpc":"2.0","method":"debug_getRawTransaction","params":["0x0000000000000000000000000000000000000000000000000000000000000000"],"id":1}Before (incorrect):
{"jsonrpc":"2.0","error":{"code":-32001,"message":"Transaction 0x000...000 was not found"},"id":1}After (correct):
{"jsonrpc":"2.0","result":null,"id":1}Root Cause
The not-found branch in
debug_getRawTransactioncalledResultWrapper<...>.Fail(...)instead ofResultWrapper<...>.Success(null).Fix
DebugRpcModule.cs: ReplaceFail(...)withSuccess(null)in the null-transaction branch.DebugModuleTests.cs: Remove the "RawTransaction" case from the sharedDebugGetRaw_WhenResourceMissing_ReturnsResourceNotFoundtest (which expected an error) and add a dedicatedDebugGetRawTransaction_WhenTransactionNotFound_ReturnsNulltest asserting the correctnullresult.References
eth_getRawTransactionByHashin Nethermind already returnsnullfor missing transactions (consistent behaviour).nullwhen not found.