From d76f8f5132d474510fa7ec1f52fce8857bfc4a4c Mon Sep 17 00:00:00 2001 From: Joel Joseph Mathews Date: Sat, 2 May 2026 16:49:00 +0530 Subject: [PATCH 1/2] fix:lint errors in tools/configtxlator Signed-off-by: Joel Joseph Mathews --- tools/configtxlator/main.go | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/tools/configtxlator/main.go b/tools/configtxlator/main.go index c1c0bfa..24a9640 100644 --- a/tools/configtxlator/main.go +++ b/tools/configtxlator/main.go @@ -121,7 +121,8 @@ func startServer(address string, cors []string) { methods := handlers.AllowedMethods([]string{http.MethodPost}) headers := handlers.AllowedHeaders([]string{"Content-Type"}) logger.Infof("Serving HTTP requests on %s with CORS %v", listener.Addr(), cors) - err = http.Serve(listener, handlers.CORS(origins, methods, headers)(rest.NewRouter())) + corsHandler := handlers.CORS(origins, methods, headers) + err = http.Serve(listener, corsHandler(rest.NewRouter())) } else { logger.Infof("Serving HTTP requests on %s", listener.Addr()) err = http.Serve(listener, rest.NewRouter()) @@ -141,7 +142,11 @@ func encodeProto(msgName string, input, output *os.File) error { if msgType == nil { return errors.Errorf("message of type %s unknown", msgType) } - msg := reflect.New(msgType.Elem()).Interface().(proto.Message) + msg, ok := reflect.New(msgType.Elem()).Interface().(proto.Message) + + if !ok { + return errors.New("error marshaling: invalid type") + } err = protolator.DeepUnmarshalJSON(input, msg) if err != nil { @@ -175,7 +180,10 @@ func decodeProto(msgName string, input, output *os.File) error { if msgType == nil { return errors.Errorf("message of type %s unknown", msgType) } - msg := reflect.New(msgType.Elem()).Interface().(proto.Message) + msg, ok := reflect.New(msgType.Elem()).Interface().(proto.Message) + if !ok { + return errors.New("error marshaling: invalid type") + } in, err := io.ReadAll(input) if err != nil { @@ -223,11 +231,12 @@ func computeUpdt(original, updated, output *os.File, channelID string) error { return errors.Wrapf(err, "error computing config update") } - cu.ChannelId = channelID - if cu == nil { return errors.New("error marshaling computed config update: proto: Marshal called with nil") } + + cu.ChannelId = channelID + outBytes, err := proto.Marshal(cu) if err != nil { return errors.Wrapf(err, "error marshaling computed config update") From 9c9c78544191a20d00ceed562d525f73208d793e Mon Sep 17 00:00:00 2001 From: Joel Joseph Mathews Date: Sat, 2 May 2026 17:02:08 +0530 Subject: [PATCH 2/2] add default case Signed-off-by: Joel Joseph Mathews --- tools/configtxlator/main.go | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tools/configtxlator/main.go b/tools/configtxlator/main.go index 24a9640..78c9144 100644 --- a/tools/configtxlator/main.go +++ b/tools/configtxlator/main.go @@ -103,6 +103,8 @@ func main() { // "version" command case versionCmd.FullCommand(): fmt.Println(getVersionInfo()) + default: + app.Fatalf("Unknown command") } }