From 56ea4b5c6382c83795a59253882273ef15a37675 Mon Sep 17 00:00:00 2001 From: Hayden B Date: Tue, 19 Nov 2024 05:37:12 -0800 Subject: [PATCH] Add error message when computing consistency proof (#2278) The service would panic if firstSize > lastSize because the error object was not created. Signed-off-by: Hayden Blauzvern --- pkg/api/tlog.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/pkg/api/tlog.go b/pkg/api/tlog.go index 45813c23d..96e3be2bf 100644 --- a/pkg/api/tlog.go +++ b/pkg/api/tlog.go @@ -123,7 +123,8 @@ func stringPointer(s string) *string { // GetLogProofHandler returns information required to compute a consistency proof between two snapshots of log func GetLogProofHandler(params tlog.GetLogProofParams) middleware.Responder { if *params.FirstSize > params.LastSize { - return handleRekorAPIError(params, http.StatusBadRequest, nil, fmt.Sprintf(firstSizeLessThanLastSize, *params.FirstSize, params.LastSize)) + errMsg := fmt.Sprintf(firstSizeLessThanLastSize, *params.FirstSize, params.LastSize) + return handleRekorAPIError(params, http.StatusBadRequest, fmt.Errorf("consistency proof: %s", errMsg), errMsg) } tc := trillianclient.NewTrillianClient(params.HTTPRequest.Context(), api.logClient, api.logID) if treeID := swag.StringValue(params.TreeID); treeID != "" {