Skip to content

Commit

Permalink
fix: wrap errors in auto CLI service registration
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
mark-rushakoff committed May 30, 2024
1 parent 4d4b706 commit d95b4bc
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions runtime/v2/services/autocli.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package services

import (
"context"
"fmt"

"github.com/cosmos/gogoproto/proto"
"google.golang.org/grpc"
Expand Down Expand Up @@ -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
}

Expand Down

0 comments on commit d95b4bc

Please sign in to comment.