hyperledger/fabric · error
error encode input
Error message
error encode input
What it means
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.
Source
Thrown at cmd/configtxlator/main.go:131
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()))
} else {
logger.Infof("Serving HTTP requests on %s", listener.Addr())
err = http.Serve(listener, rest.NewRouter())
}
app.Fatalf("Error starting server:[%s]\n", err)
}
func printVersion() {
fmt.Println(metadata.GetVersionInfo())
}
func encodeProto(msgName string, input, output *os.File) error {
mt, err := protoregistry.GlobalTypes.FindMessageByName(protoreflect.FullName(msgName))
if err != nil {
return errors.Wrapf(err, "error encode input")
}
msgType := reflect.TypeOf(mt.Zero().Interface())
if msgType == nil {
return errors.Errorf("message of type %s unknown", msgType)
}
msg := reflect.New(msgType.Elem()).Interface().(proto.Message)
err = protolator.DeepUnmarshalJSON(input, msg)
if err != nil {
return errors.Wrapf(err, "error decoding input")
}
if msg == nil {
return errors.New("error marshaling: proto: Marshal called with nil")
}
out, err := proto.Marshal(msg)View on GitHub (pinned to 2736b63f8f)
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.
Example fix
// before $ configtxlator proto_encode --type Config --input config.json --output config.pb // unqualified name // after $ configtxlator proto_encode --type common.Config --input config.json --output config.pb
Defensive patterns
Strategy: validation
Validate before calling
// Validate the --type value against known registered names before invoking configtxlator
const knownTypes = ['common.Config', 'common.Envelope', 'common.ConfigUpdate', 'common.Block']
if !knownTypes.includes(typeArg) {
throw new Error(`--type must be fully qualified, e.g. common.Config (got: ${typeArg})`)
} Type guard
func isKnownProtoMessageType(name string) bool {
_, err := protoregistry.GlobalTypes.FindMessageByName(protoreflect.FullName(name))
return err == nil
} Try / catch
out, err := exec.Command("configtxlator", "proto_encode", "--type", msgType, ...).CombinedOutput()
if err != nil && strings.Contains(string(out), "error encode input") {
return fmt.Errorf("unknown --type %q; use fully qualified name like common.Config", msgType)
} Prevention
- 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.
When it happens
Trigger: 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.
Common situations: 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.
Related errors
- message of type %s unknown
- error marshaling: proto: Marshal called with nil
- error marshaling
- failed to marshal InstallChaincodeArgs
- malformed org definition for org: %s
AI-assisted analysis of hyperledger/fabric@2736b63f8f (2026-09-04).
Data as JSON: /api/errors/781a327ab18703a8.
Report an issue: GitHub.