hyperledger/fabric · error
marshal-failed
Error message
marshal-failed
What it means
PendingQueryResult.Add guard: the query result object passed in does not implement proto.Message (or proto.Marshal failed), so it cannot be serialized into the response batch — a chaincode/ledger-side type mismatch.
Source
Thrown at core/chaincode/pending_query_result.go:30
"github.com/pkg/errors"
"google.golang.org/protobuf/proto"
)
type PendingQueryResult struct {
batch []*pb.QueryResultBytes
}
func (p *PendingQueryResult) Cut() []*pb.QueryResultBytes {
batch := p.batch
p.batch = nil
return batch
}
func (p *PendingQueryResult) Add(queryResult commonledger.QueryResult) error {
_, ok := queryResult.(proto.Message)
if !ok {
chaincodeLogger.Error("failed to marshal query result: proto is nil")
return errors.New("marshal-failed")
}
queryResultBytes, err := proto.Marshal(queryResult.(proto.Message))
if err != nil {
chaincodeLogger.Errorf("failed to marshal query result: %s", err)
return err
}
p.batch = append(p.batch, &pb.QueryResultBytes{ResultBytes: queryResultBytes})
return nil
}
func (p *PendingQueryResult) Size() int {
return len(p.batch)
}
View on GitHub (pinned to 2736b63f8f)
Solutions
- Ensure query iterators return protobuf-based result types
- Check the peer log line 'failed to marshal query result' for the marshal failure detail
Defensive patterns
Strategy: validation
When it happens
Trigger: Thrown at core/chaincode/pending_query_result.go:30 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of hyperledger/fabric@2736b63f8f (2026-09-04).
Data as JSON: /api/errors/5a72365a450ded5b.
Report an issue: GitHub.