{"record":{"id":"5a72365a450ded5b","repo":"hyperledger/fabric","slug":"marshal-failed-5a7236","errorCode":null,"errorMessage":"marshal-failed","messagePattern":"marshal-failed","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"core/chaincode/pending_query_result.go","lineNumber":30,"sourceCode":"\t\"github.com/pkg/errors\"\n\t\"google.golang.org/protobuf/proto\"\n)\n\ntype PendingQueryResult struct {\n\tbatch []*pb.QueryResultBytes\n}\n\nfunc (p *PendingQueryResult) Cut() []*pb.QueryResultBytes {\n\tbatch := p.batch\n\tp.batch = nil\n\treturn batch\n}\n\nfunc (p *PendingQueryResult) Add(queryResult commonledger.QueryResult) error {\n\t_, ok := queryResult.(proto.Message)\n\tif !ok {\n\t\tchaincodeLogger.Error(\"failed to marshal query result: proto is nil\")\n\t\treturn errors.New(\"marshal-failed\")\n\t}\n\tqueryResultBytes, err := proto.Marshal(queryResult.(proto.Message))\n\tif err != nil {\n\t\tchaincodeLogger.Errorf(\"failed to marshal query result: %s\", err)\n\t\treturn err\n\t}\n\tp.batch = append(p.batch, &pb.QueryResultBytes{ResultBytes: queryResultBytes})\n\treturn nil\n}\n\nfunc (p *PendingQueryResult) Size() int {\n\treturn len(p.batch)\n}\n","sourceCodeStart":12,"sourceCodeEnd":44,"githubUrl":"https://github.com/hyperledger/fabric/blob/2736b63f8fd5932511d56fe68b7039d15977f7f6/core/chaincode/pending_query_result.go#L12-L44","documentation":"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.","triggerScenarios":"Thrown at core/chaincode/pending_query_result.go:30 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Ensure query iterators return protobuf-based result types","Check the peer log line 'failed to marshal query result' for the marshal failure detail"],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"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"}