Skip to content

Commit

Permalink
Guard against nil etcd response header (#4339)
Browse files Browse the repository at this point in the history
  • Loading branch information
amdprophet committed Jun 25, 2021
1 parent 2c4811d commit d1480a4
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions cli/commands/cluster/health.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package cluster

import (
"errors"
"fmt"
"io"

Expand All @@ -23,6 +24,9 @@ func HealthCommand(cli *cli.SensuCli) *cobra.Command {
if err != nil {
return err
}
if result.Header == nil {
return errors.New("result header was empty, etcd cluster may be down")
}
err = helpers.PrintTitle(helpers.GetChangedStringValueFlag("format", cmd.Flags()), cli.Config.Format(), fmt.Sprintf("Etcd Cluster ID: %x", result.Header.ClusterId), cmd.OutOrStdout())
if err != nil {
return err
Expand Down

0 comments on commit d1480a4

Please sign in to comment.