From d0ab92540dad28dfa01cd21c879bff20814e22e2 Mon Sep 17 00:00:00 2001 From: Arkadiy Kukarkin Date: Thu, 23 Apr 2026 16:11:05 +0200 Subject: [PATCH] api: fix out-of-bounds on lone-error handler returns When a registered handler returns only an error (e.g. ResetHandler, InitHandler, RemovePreparationHandler), len(results) == 1. The branch that handles this case was indexing results[1] to extract the error, which panics the request goroutine on any non-nil error. Use results[0] since the only result value is the error itself. --- api/api.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/api/api.go b/api/api.go index 8c2d8a2c0..13a98d49b 100644 --- a/api/api.go +++ b/api/api.go @@ -281,7 +281,7 @@ func (s *Server) toEchoHandler(handlerFunc any) echo.HandlerFunc { if len(results) == 1 { // Handle the returned error if results[0].Interface() != nil { - err, ok := results[1].Interface().(error) + err, ok := results[0].Interface().(error) if !ok { return c.JSON(http.StatusInternalServerError, HTTPError{Err: "invalid handler function signature"}) }