Skip to content

bug: NewBackend() panics instead of returning error on config/client failures #1036

@Aboudjem

Description

@Aboudjem

Bug Description

In rpc/backend/backend.go, NewBackend() uses panic() for two failure conditions:

appConf, err := config.GetConfig(ctx.Viper)
if err != nil {
    panic(err)  // Line ~210
}

rpcClient, ok := clientCtx.Client.(tmrpcclient.SignClient)
if !ok {
    panic(fmt.Sprintf("invalid rpc client..."))  // Line ~215
}

Impact

  • Any operator misconfiguration in app.toml causes an unrecoverable crash with an unhelpful panic trace
  • A wrong client type produces a panic instead of a descriptive error
  • All 5 callers in rpc/apis.go have no way to handle these failures gracefully

Proposed Fix

Change NewBackend signature to return (*Backend, error) and replace panics with error returns. Update all 5 callers in rpc/apis.go.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions