From 5a2e51b8945308a5bf6fa3256d26cde9001a9514 Mon Sep 17 00:00:00 2001 From: Snezhkko Date: Tue, 9 Dec 2025 15:56:00 +0200 Subject: [PATCH] fix(rpc): incorrect constructor return type (#16084) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The constructor `NewStateRootNotFoundError` incorrectly returned `StateNotFoundError`. This prevented handlers that rely on errors.As(err, *lookup.StateRootNotFoundError) from matching and mapping the error to HTTP 404. The function now returns StateRootNotFoundError and constructs that type, restoring the intended behavior for “state root not found” cases. --------- Co-authored-by: Radosław Kapka --- beacon-chain/rpc/lookup/stater.go | 4 ++-- changelog/Snezhkko_fix-type.md | 3 +++ 2 files changed, 5 insertions(+), 2 deletions(-) create mode 100644 changelog/Snezhkko_fix-type.md diff --git a/beacon-chain/rpc/lookup/stater.go b/beacon-chain/rpc/lookup/stater.go index b0fd36b6cd..a3bd0f250f 100644 --- a/beacon-chain/rpc/lookup/stater.go +++ b/beacon-chain/rpc/lookup/stater.go @@ -82,8 +82,8 @@ type StateRootNotFoundError struct { } // NewStateRootNotFoundError creates a new error instance. -func NewStateRootNotFoundError(stateRootsSize int) StateNotFoundError { - return StateNotFoundError{ +func NewStateRootNotFoundError(stateRootsSize int) StateRootNotFoundError { + return StateRootNotFoundError{ message: fmt.Sprintf("state root not found in the last %d state roots", stateRootsSize), } } diff --git a/changelog/Snezhkko_fix-type.md b/changelog/Snezhkko_fix-type.md new file mode 100644 index 0000000000..264398fb20 --- /dev/null +++ b/changelog/Snezhkko_fix-type.md @@ -0,0 +1,3 @@ +## Fixed + +- incorrect constructor return type [#16084](https://github.com/OffchainLabs/prysm/pull/16084)