Skip to content

debug_getRawTransaction: return null instead of error for missing transaction#12151

Merged
svlachakis merged 1 commit into
masterfrom
fix/debug-get-raw-transaction-null-not-found
Jun 26, 2026
Merged

debug_getRawTransaction: return null instead of error for missing transaction#12151
svlachakis merged 1 commit into
masterfrom
fix/debug-get-raw-transaction-null-not-found

Conversation

@manusw7

@manusw7 manusw7 commented Jun 26, 2026

Copy link
Copy Markdown
Contributor

Description

DebugRpcModule.debug_getRawTransaction was 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 own eth_getRawTransactionByHash implementation — is to return a successful response with a null result.

Steps to Reproduce

Call debug_getRawTransaction with 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_getRawTransaction called ResultWrapper<...>.Fail(...) instead of ResultWrapper<...>.Success(null).

Fix

  • DebugRpcModule.cs: Replace Fail(...) with Success(null) in the null-transaction branch.
  • DebugModuleTests.cs: Remove the "RawTransaction" case from the shared DebugGetRaw_WhenResourceMissing_ReturnsResourceNotFound test (which expected an error) and add a dedicated DebugGetRawTransaction_WhenTransactionNotFound_ReturnsNull test asserting the correct null result.

References

  • eth_getRawTransactionByHash in Nethermind already returns null for missing transactions (consistent behaviour).
  • Execution-apis spec: transaction-by-hash methods return null when not found.

…g transaction

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@claude

claude Bot commented Jun 26, 2026

Copy link
Copy Markdown
Contributor

Claude finished @manusw7's task in 1m 32s —— View job


PR Review: debug_getRawTransaction returns null instead of error

  • Read changed files (DebugRpcModule.cs, DebugModuleTests.cs)
  • Verify consistency with eth_getRawTransactionByHash
  • Check tests and edge cases
  • Review nullability / compiler-warning implications

Summary

The change is correct, minimal, and well-tested. ✅

debug_getRawTransaction now returns a successful null result for a missing transaction instead of a -32001 ResourceNotFound error, matching:

  • Nethermind's own eth_getRawTransactionByHash (EthRpcModule.cs:622-633), which already returns Success(null) for a missing tx, and
  • the execution-apis convention that tx-by-hash lookups return null when not found.

The test changes are appropriate: the RawTransaction case is removed from the shared DebugGetRaw_WhenResourceMissing_ReturnsResourceNotFound source (RawMissingCases now correctly contains only the debug_getRawBlock cases, which still legitimately error), and a dedicated DebugGetRawTransaction_WhenTransactionNotFound_ReturnsNull test asserts the exact {"result":null} payload. There's also already a positive-path test (DebugGetRawTransaction_WhenTransactionExists_ReturnsTransactionRlp), so both branches are covered.

I confirmed Nethermind.JsonRpc.csproj uses <Nullable>annotations</Nullable>, so ResultWrapper<ArrayPoolList<byte>>.Success(null) compiles without a nullability warning despite the non-nullable type parameter — no build impact.

Findings

Low — Minor type-annotation inconsistency: eth_getRawTransactionByHash declares ResultWrapper<ArrayPoolList<byte>?> (nullable), whereas debug_getRawTransaction keeps ResultWrapper<ArrayPoolList<byte>> (non-nullable) at both the interface (IDebugRpcModule.cs:106) and implementation. The result type can now legitimately be null, so the nullable annotation would document the contract more accurately and fully mirror the eth_ method. This is purely cosmetic (no warning under Nullable=annotations) and optional — not a blocker.

No Critical, High, or Medium issues found. No disposal/resource concerns (the null path allocates nothing). Behavior is now spec-compliant and consistent across modules.

Verdict: looks good to merge.

@svlachakis svlachakis 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.

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?

@manusw7

manusw7 commented Jun 26, 2026

Copy link
Copy Markdown
Contributor Author

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 eth_getRawTransactionByHash already returns null for missing transactions (consistent behavior within the codebase).

The spec reference chcked is execution-apis#transaction.yaml, where all eth_getTransactionBy* define their results as oneOf: [notFound, bytes] where notFound is {type: null}.

For debug_getRawTransaction specifically, the spec is missing the notFound alternative entirely execution-apis#getters.yaml (it only declared the success bytes path) — that gap is being fixed in ethereum/execution-apis#836.
Geth instead returns "0x" for missing transactions on this method; but this go-ethereum#35227 will align that.

Decide if we want to merge to have consistent behavior within the codebase, or we should wait for the above PRs first

@svlachakis svlachakis merged commit 4bfa334 into master Jun 26, 2026
794 of 796 checks passed
@svlachakis svlachakis deleted the fix/debug-get-raw-transaction-null-not-found branch June 26, 2026 15:18
@svlachakis

Copy link
Copy Markdown
Contributor

@manusw7 why you did it makes sense, overall it doesn't make sense to return nulls instead of user friendly error messages

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants