From d95b4bcc51bcd03ee3f7d3aad456ff3997de7b14 Mon Sep 17 00:00:00 2001 From: Mark Rushakoff Date: Thu, 30 May 2024 14:43:31 -0400 Subject: [PATCH] fix: wrap errors in auto CLI service registration The current code in #20412, when attempting to run simd, was failing with the error: panic: proto: not found" Wrapping the error returned by FindDescriptorByName gave a more informative error: panic: failed to find descriptor for "cosmos.accounts.v1.Msg": proto: not found However, there is an earlier root cause. The a.err field was set due to a failure in proto.MergedRegistry but later overridden. Fixing that early return now shows the root cause: panic: failed to build registry cache: proto: could not resolve import "tendermint/abci/types.proto": not found Helps #20492. --- runtime/v2/services/autocli.go | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/runtime/v2/services/autocli.go b/runtime/v2/services/autocli.go index 281d9f8c0301..85aeb20b702d 100644 --- a/runtime/v2/services/autocli.go +++ b/runtime/v2/services/autocli.go @@ -2,6 +2,7 @@ package services import ( "context" + "fmt" "github.com/cosmos/gogoproto/proto" "google.golang.org/grpc" @@ -104,11 +105,16 @@ type autocliRegistrar struct { func (a *autocliRegistrar) RegisterService(sd *grpc.ServiceDesc, ss interface{}) { if a.registryCache == nil { a.registryCache, a.err = proto.MergedRegistry() + if a.err != nil { + a.err = fmt.Errorf("failed to build registry cache: %w", a.err) + return + } } - desc, err := a.registryCache.FindDescriptorByName(protoreflect.FullName(sd.ServiceName)) + fullName := protoreflect.FullName(sd.ServiceName) + desc, err := a.registryCache.FindDescriptorByName(fullName) if err != nil { - a.err = err + a.err = fmt.Errorf("failed to find descriptor for %q: %w", fullName, err) return }