hyperledger/fabric · error
failed to marshal args
Error message
failed to marshal args
What it means
This error is returned by InstalledQuerier.createProposal in the `peer chaincode queryinstalled` command when protobuf serialization of the empty lb.QueryInstalledChaincodesArgs message fails. The args message is empty, so marshaling practically never fails; the wrap exists to surface any proto subsystem failure with context before building the ChaincodeInput proposal for the _lifecycle system chaincode.
Source
Thrown at internal/peer/lifecycle/chaincode/queryinstalled.go:156
func (i *InstalledQuerier) printResponse(proposalResponse *pb.ProposalResponse) error {
qicr := &lb.QueryInstalledChaincodesResult{}
err := proto.Unmarshal(proposalResponse.Response.Payload, qicr)
if err != nil {
return errors.Wrap(err, "failed to unmarshal proposal response's response payload")
}
fmt.Fprintln(i.Writer, "Installed chaincodes on peer:")
for _, chaincode := range qicr.InstalledChaincodes {
fmt.Fprintf(i.Writer, "Package ID: %s, Label: %s\n", chaincode.PackageId, chaincode.Label)
}
return nil
}
func (i *InstalledQuerier) createProposal() (*pb.Proposal, error) {
args := &lb.QueryInstalledChaincodesArgs{}
argsBytes, err := proto.Marshal(args)
if err != nil {
return nil, errors.Wrap(err, "failed to marshal args")
}
ccInput := &pb.ChaincodeInput{
Args: [][]byte{[]byte("QueryInstalledChaincodes"), argsBytes},
}
cis := &pb.ChaincodeInvocationSpec{
ChaincodeSpec: &pb.ChaincodeSpec{
ChaincodeId: &pb.ChaincodeID{Name: lifecycleName},
Input: ccInput,
},
}
signerSerialized, err := i.Signer.Serialize()
if err != nil {
return nil, errors.WithMessage(err, "failed to serialize identity")
}
View on GitHub (pinned to 2736b63f8f)
Solutions
- Rebuild the peer CLI from unmodified Fabric source so the _lifecycle protobuf types are generated consistently.
- Check that the protobuf dependency versions (google.golang.org/protobuf vs github.com/golang/protobuf) are aligned in your build.
- Inspect the wrapped underlying proto error (errors.Wrap keeps the cause) to identify the exact marshal failure and fix the offending message type registration.
Defensive patterns
Strategy: try-catch
Validate before calling
if _, err := proto.Marshal(&lb.QueryInstalledChaincodesArgs{}); err != nil { return fmt.Errorf("proto runtime broken: %w", err) } Try / catch
if err := runQueryInstalled(); err != nil {
if strings.Contains(err.Error(), "failed to marshal args") {
log.Fatalf("proto registry/build issue: %v", err)
}
return err
} Prevention
- Build the CLI from unmodified upstream Fabric sources.
- Keep protobuf runtime and generated code versions aligned.
- Run peer CLI unit tests that exercise _lifecycle queries before deployment.
When it happens
Trigger: Calling Query -> createProposal when proto.Marshal(args) returns a non-nil error; essentially only occurs if the proto registry/runtime is corrupted or the generated type registration is broken in a custom build.
Common situations: Custom or patched Fabric builds with mismatched _lifecycle protobuf definitions; vendoring issues where generated pb.go files are out of sync with the protobuf library version; exotic proto compilation/tag errors.
Related errors
- cannot query joinbysnapshot status, due to %s
- error unmarshalling
- error encoding output
- error unmarshalling original config
- error unmarshalling updated config
AI-assisted analysis of hyperledger/fabric@2736b63f8f (2026-09-04).
Data as JSON: /api/errors/5cd5b555d067851f.
Report an issue: GitHub.