{"record":{"id":"781a327ab18703a8","repo":"hyperledger/fabric","slug":"error-encode-input","errorCode":null,"errorMessage":"error encode input","messagePattern":"error encode input","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cmd/configtxlator/main.go","lineNumber":131,"sourceCode":"\t\theaders := handlers.AllowedHeaders([]string{\"Content-Type\"})\n\t\tlogger.Infof(\"Serving HTTP requests on %s with CORS %v\", listener.Addr(), cors)\n\t\terr = http.Serve(listener, handlers.CORS(origins, methods, headers)(rest.NewRouter()))\n\t} else {\n\t\tlogger.Infof(\"Serving HTTP requests on %s\", listener.Addr())\n\t\terr = http.Serve(listener, rest.NewRouter())\n\t}\n\n\tapp.Fatalf(\"Error starting server:[%s]\\n\", err)\n}\n\nfunc printVersion() {\n\tfmt.Println(metadata.GetVersionInfo())\n}\n\nfunc encodeProto(msgName string, input, output *os.File) error {\n\tmt, err := protoregistry.GlobalTypes.FindMessageByName(protoreflect.FullName(msgName))\n\tif err != nil {\n\t\treturn errors.Wrapf(err, \"error encode input\")\n\t}\n\n\tmsgType := reflect.TypeOf(mt.Zero().Interface())\n\n\tif msgType == nil {\n\t\treturn errors.Errorf(\"message of type %s unknown\", msgType)\n\t}\n\tmsg := reflect.New(msgType.Elem()).Interface().(proto.Message)\n\n\terr = protolator.DeepUnmarshalJSON(input, msg)\n\tif err != nil {\n\t\treturn errors.Wrapf(err, \"error decoding input\")\n\t}\n\n\tif msg == nil {\n\t\treturn errors.New(\"error marshaling: proto: Marshal called with nil\")\n\t}\n\tout, err := proto.Marshal(msg)","sourceCodeStart":113,"sourceCodeEnd":149,"githubUrl":"https://github.com/hyperledger/fabric/blob/2736b63f8fd5932511d56fe68b7039d15977f7f6/cmd/configtxlator/main.go#L113-L149","documentation":"In `encodeProto` (cmd/configtxlator/main.go:131), `protoregistry.GlobalTypes.FindMessageByName` could not locate a registered proto message type for the name given via `-type`. configtxlator uses the name to look up the message descriptor; an unknown or misspelled type name causes this wrapped 'error encode input' failure.","triggerScenarios":"Running `configtxlator proto_encode --type <name>` where <name> is not a fully-qualified registered proto message name, e.g. missing package prefix, wrong casing, or a message that does not exist in the compiled-in registry.","commonSituations":"Typing 'common.Config' instead of the fully qualified 'common.Config' vs actual registry names (correct form is e.g. 'common.Config', 'common.Envelope', 'peer.Configuration'); Fabric version where the message moved/renamed; trailing whitespace or wrong path separator.","solutions":["Use the exact fully-qualified proto message name, e.g. --type common.Config or --type common.Envelope.","Check casing and package prefix — the lookup is by protoreflect.FullName and is case-sensitive.","Confirm the message exists in your Fabric version (run configtxlator without args or check the protos in the fabric-protos repo).","Avoid shell-quoting artifacts (extra spaces/newlines) in the --type argument."],"exampleFix":"// before\n$ configtxlator proto_encode --type Config --input config.json --output config.pb   // unqualified name\n// after\n$ configtxlator proto_encode --type common.Config --input config.json --output config.pb","handlingStrategy":"validation","validationCode":"// Validate the --type value against known registered names before invoking configtxlator\nconst knownTypes = ['common.Config', 'common.Envelope', 'common.ConfigUpdate', 'common.Block']\nif !knownTypes.includes(typeArg) {\n  throw new Error(`--type must be fully qualified, e.g. common.Config (got: ${typeArg})`)\n}","typeGuard":"func isKnownProtoMessageType(name string) bool {\n\t_, err := protoregistry.GlobalTypes.FindMessageByName(protoreflect.FullName(name))\n\treturn err == nil\n}","tryCatchPattern":"out, err := exec.Command(\"configtxlator\", \"proto_encode\", \"--type\", msgType, ...).CombinedOutput()\nif err != nil && strings.Contains(string(out), \"error encode input\") {\n\treturn fmt.Errorf(\"unknown --type %q; use fully qualified name like common.Config\", msgType)\n}","preventionTips":["Always use fully-qualified proto names (package.Message) with the CLI flag quoted.","Keep a cheatsheet of common types: common.Config, common.Envelope, common.ConfigUpdate, common.Block.","Check the fabric-protos repo for the message path when unsure.","Watch for shell-mangled arguments (spaces/newlines) in scripts."],"tags":["hyperledger-fabric","configtxlator","protobuf","cli"],"backgroundTag":"unknown-proto-message-type","analyzedSha":"2736b63f8fd5932511d56fe68b7039d15977f7f6","analyzedAt":"2026-09-04T08:52:36.465Z","contentChangedAt":"2026-09-04T08:52:36.465Z","schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}