diff --git a/tools/cassandra/setupTask_test.go b/tools/cassandra/setupTask_test.go index 6e50181e2b4..9a88d497964 100644 --- a/tools/cassandra/setupTask_test.go +++ b/tools/cassandra/setupTask_test.go @@ -47,7 +47,9 @@ func TestSetupSchemaTestSuite(t *testing.T) { } func (s *SetupSchemaTestSuite) SetupSuite() { - os.Setenv("CASSANDRA_HOST", environment.GetCassandraAddress()) + if err := os.Setenv("CASSANDRA_HOST", environment.GetCassandraAddress()); err != nil { + s.Logger.Fatal("Failed to set CASSANDRA_HOST", tag.Error(err)) + } client, err := newTestCQLClient(systemKeyspace) if err != nil { s.Logger.Fatal("Error creating CQLClient", tag.Error(err)) diff --git a/tools/tdbg/app_test.go b/tools/tdbg/app_test.go index aa350c54904..e251c9975cc 100644 --- a/tools/tdbg/app_test.go +++ b/tools/tdbg/app_test.go @@ -69,7 +69,7 @@ func (s *utilSuite) TestAcceptStringSliceArgsWithCommas() { }, }, } - app.Run([]string{"testapp", "dostuff", + s.NoError(app.Run([]string{"testapp", "dostuff", "--input", `{"field1": 34, "field2": false}`, - "--input", `{"numbers": [4,5,6]}`}) + "--input", `{"numbers": [4,5,6]}`})) } diff --git a/tools/tdbg/dlq_commands.go b/tools/tdbg/dlq_commands.go index d0a9a7de6c6..1ddc7620fbf 100644 --- a/tools/tdbg/dlq_commands.go +++ b/tools/tdbg/dlq_commands.go @@ -29,6 +29,7 @@ import ( "os" "github.com/urfave/cli/v2" + "go.uber.org/multierr" "go.temporal.io/server/api/adminservice/v1" enumsspb "go.temporal.io/server/api/enums/v1" @@ -44,7 +45,7 @@ const ( ) // AdminGetDLQMessages gets DLQ metadata -func AdminGetDLQMessages(c *cli.Context) error { +func AdminGetDLQMessages(c *cli.Context) (err error) { ctx, cancel := newContext(c) defer cancel() @@ -56,7 +57,10 @@ func AdminGetDLQMessages(c *cli.Context) error { if err != nil { return err } - defer outputFile.Close() + defer func() { + // see https://pkg.go.dev/go.uber.org/multierr#hdr-Deferred_Functions + err = multierr.Combine(err, outputFile.Close()) + }() remainingMessageCount := common.EndMessageID if c.IsSet(FlagMaxMessageCount) { diff --git a/tools/tdbg/factory.go b/tools/tdbg/factory.go index 88d224a5d23..5738358da0a 100644 --- a/tools/tdbg/factory.go +++ b/tools/tdbg/factory.go @@ -39,6 +39,7 @@ import ( "github.com/urfave/cli/v2" "go.temporal.io/api/workflowservice/v1" + "go.uber.org/multierr" "google.golang.org/grpc" "google.golang.org/grpc/credentials" "google.golang.org/grpc/credentials/insecure" @@ -193,11 +194,15 @@ func fetchCACert(pathOrUrl string) (caPool *x509.CertPool, err error) { } if strings.HasPrefix(pathOrUrl, "https://") { - resp, err := netClient.Get(pathOrUrl) + var resp *http.Response + resp, err = netClient.Get(pathOrUrl) if err != nil { return nil, err } - defer resp.Body.Close() + defer func() { + // see https://pkg.go.dev/go.uber.org/multierr#hdr-Deferred_Functions + err = multierr.Combine(err, resp.Body.Close()) + }() caBytes, err = io.ReadAll(resp.Body) if err != nil { return nil, err diff --git a/tools/tdbg/util.go b/tools/tdbg/util.go index 6c7e898cb41..4921cccfdac 100644 --- a/tools/tdbg/util.go +++ b/tools/tdbg/util.go @@ -250,7 +250,9 @@ func paginate[V any](c *cli.Context, paginationFn collection.PaginationFn[V], pa pageItems = append(pageItems, item) if len(pageItems) == pageSize || !iter.HasNext() { if isTableView { - printTable(pageItems) + if err := printTable(pageItems); err != nil { + return err + } } else { prettyPrintJSONObject(pageItems) }