hyperledger/fabric · error
service message type not valid
Error message
service message type not valid
What it means
BuildStepRequest only supports StepRequests whose oneof payload is either a ConsensusRequest or a SubmitRequest. If neither GetConsensusRequest() nor GetSubmitRequest() yields a non-nil message, it returns 'service message type not valid' — the StepRequest carried no recognized payload for the node cluster service.
Source
Thrown at orderer/common/cluster/commauth.go:324
NodeConrequest: &orderer.NodeConsensusRequest{
Payload: consReq.Payload,
Metadata: consReq.Metadata,
},
},
}
return stepRequest, nil
} else if subReq := request.GetSubmitRequest(); subReq != nil {
stepRequest = &orderer.ClusterNodeServiceStepRequest{
Payload: &orderer.ClusterNodeServiceStepRequest_NodeTranrequest{
NodeTranrequest: &orderer.NodeTransactionOrderRequest{
Payload: subReq.Payload,
LastValidationSeq: subReq.LastValidationSeq,
},
},
}
return stepRequest, nil
}
return nil, errors.New("service message type not valid")
}
func BuildStepRespone(stepResponse *orderer.ClusterNodeServiceStepResponse) (*orderer.StepResponse, error) {
if stepResponse == nil {
return nil, errors.New("input response object is nil")
}
if respPayload := stepResponse.GetTranorderRes(); respPayload != nil {
stepResponse := &orderer.StepResponse{
Payload: &orderer.StepResponse_SubmitRes{
SubmitRes: &orderer.SubmitResponse{
Channel: respPayload.Channel,
Status: respPayload.Status,
},
},
}
return stepResponse, nil
}
return nil, errors.New("service stream returned with invalid response type")View on GitHub (pinned to 2736b63f8f)
Solutions
- Ensure every StepRequest you send has either Payload set to &orderer.StepRequest_ConsensusRequest{...} or &orderer.StepRequest_SubmitRequest{...}.
- Check proto/generated-code versions on both sides are in sync; update this mapper if a new payload type was introduced.
- At the call site, verify the request's GetPayload() is non-nil before calling Send.
Example fix
// before
req := &orderer.StepRequest{} // payload unset
err := stream.Send(req) // "service message type not valid"
// after
req := &orderer.StepRequest{
Payload: &orderer.StepRequest_ConsensusRequest{
ConsensusRequest: &orderer.ConsensusRequest{
Payload: payloadBytes,
Metadata: metaBytes,
},
},
}
err := stream.Send(req) Defensive patterns
Strategy: type-guard
Validate before calling
switch req.GetPayload().(type) {
case *orderer.StepRequest_ConsensusRequest, *orderer.StepRequest_SubmitRequest:
// ok
default:
return errors.New("StepRequest payload must be consensus or submit")
}
err := stream.Send(req) Type guard
func isSupportedPayload(r *orderer.StepRequest) bool {
return r.GetConsensusRequest() != nil || r.GetSubmitRequest() != nil
} Try / catch
if err := stream.Send(req); err != nil {
if err.Error() == "service message type not valid" {
log.Errorf("unrecognized StepRequest payload: %T", req.GetPayload())
}
return err
} Prevention
- Always set the Payload oneof when constructing StepRequest literals.
- Keep generated protobuf code and this mapper in sync across version upgrades.
- Test round-tripping every supported payload type through BuildStepRequest.
When it happens
Trigger: Calling Send() with a &orderer.StepRequest{} that has its Payload oneof unset, or set to a payload variant this mapper does not handle (e.g. a newer/other message type added to the proto).
Common situations: Constructing StepRequest literals without setting the Payload oneof field; proto version drift where a new request type was added but this mapper was not updated; unmarshaling errors leaving Payload empty.
Related errors
- error unmarshalling
- error encoding output
- error unmarshalling original config
- error unmarshalling updated config
- config must contain a channel group
AI-assisted analysis of hyperledger/fabric@2736b63f8f (2026-09-04).
Data as JSON: /api/errors/b9eacb95e202ee16.
Report an issue: GitHub.