{"record":{"id":"023b840a847904f3","repo":"hyperledger/fabric","slug":"failed-assembling-endorsers-of-channel-s","errorCode":null,"errorMessage":"failed assembling endorsers of channel %s","messagePattern":"failed assembling endorsers of channel (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"discovery/client/client.go","lineNumber":469,"sourceCode":"\tchaincodeQueryMapping map[int][]InvocationChain,\n) error {\n\tfor ch, index := range channel2index {\n\t\tccQueryRes, err := protoext.ResponseEndorsersAt(r, index)\n\t\tif ccQueryRes == nil && err == nil {\n\t\t\treturn errors.Errorf(\"expected QueryResult of either ChaincodeQueryResult or Error but got %v instead\", r.Results[index])\n\t\t}\n\n\t\tif err != nil {\n\t\t\tkey := key{\n\t\t\t\tqueryType: protoext.ChaincodeQueryType,\n\t\t\t\tk:         ch,\n\t\t\t}\n\t\t\tresp[key] = errors.New(err.Content)\n\t\t\tcontinue\n\t\t}\n\n\t\tif err := resp.mapEndorsersOfChannel(ccQueryRes, ch, chaincodeQueryMapping[index]); err != nil {\n\t\t\treturn errors.Wrapf(err, \"failed assembling endorsers of channel %s\", ch)\n\t\t}\n\t}\n\treturn nil\n}\n\nfunc (resp response) mapEndorsersOfChannel(ccRs *discovery.ChaincodeQueryResult, channel string, invocationChain []InvocationChain) error {\n\tif len(ccRs.Content) < len(invocationChain) {\n\t\treturn errors.Errorf(\"expected %d endorsement descriptors but got only %d\", len(invocationChain), len(ccRs.Content))\n\t}\n\tfor i, desc := range ccRs.Content {\n\t\texpectedCCName := invocationChain[i][0].Name\n\t\tif desc.Chaincode != expectedCCName {\n\t\t\treturn errors.Errorf(\"expected chaincode %s but got endorsement descriptor for %s\", expectedCCName, desc.Chaincode)\n\t\t}\n\t\tkey := key{\n\t\t\tqueryType:       protoext.ChaincodeQueryType,\n\t\t\tk:               channel,\n\t\t\tinvocationChain: invocationChain[i].String(),","sourceCodeStart":451,"sourceCodeEnd":487,"githubUrl":"https://github.com/hyperledger/fabric/blob/2736b63f8fd5932511d56fe68b7039d15977f7f6/discovery/client/client.go#L451-L487","documentation":"response.mapEndorsers wraps any error produced while mapping endorsers for a specific channel with \"failed assembling endorsers of channel %s\" via errors.Wrapf. The underlying error comes from mapEndorsersOfChannel (descriptor count/chaincode mismatch, missing layout group, bad endorser envelopes, etc.). The wrap adds the channel name so the caller knows which channel's chaincode query result failed to assemble.","triggerScenarios":"Any failure inside resp.mapEndorsersOfChannel while processing a channel's ChaincodeQueryResult during a discovery SendDiscoveryQuery — too few endorsement descriptors returned, chaincode name mismatch, a layout group without endorsers, or a peer whose gossip envelopes fail to unmarshal/validate.","commonSituations":"Mixed channels where one channel has stale/incomplete discovery data; invoking a chaincode chain (collections or chaincode-to-chaincode) that the server's descriptor list doesn't line up with; peers in the middle of joining a channel so envelopes are missing.","solutions":["Inspect the wrapped inner error (use github.com/pkg/errors Cause/Unwrap) to find the real failure","Verify the channel name and that peers have joined and gossiped state for it","Ensure the requested invocation chain's chaincodes are installed on peers in that channel","Retry the discovery query once peers have stabilized membership","Check discovery client/server version compatibility (Fabric v1/v2 descriptor semantics)"],"exampleFix":"// before: prints only the wrapper\nlog.Println(err)\n// after: extract cause\nlog.Printf(\"%v: %+v\", err, errors.Cause(err))","handlingStrategy":"try-catch","validationCode":"// Ensure requested channels and chaincodes exist before querying\nif len(channel2index) == 0 || len(chaincodeQueryMapping) == 0 {\n\treturn errors.New(\"no channels or chaincode interests to query\")\n}","typeGuard":null,"tryCatchPattern":"if err := resp.mapEndorsers(ch2idx, r, ccMapping); err != nil {\n\tvar chErr error\n\tif errors.As(err, &chErr) {\n\t\tlog.Printf(\"assembling endorsers failed: %+v (cause: %v)\", err, errors.Cause(err))\n\t}\n\treturn err\n}","preventionTips":["Always unwrap errors with errors.Cause/Unwrap to see the underlying failure","Log the channel name from the wrapper message before remediation","Keep client and peer Fabric versions aligned","Verify peers have stable gossip membership before issuing queries"],"tags":["hyperledger-fabric","discovery-service","channel","endorsement"],"backgroundTag":"endorsement-descriptor-assembly-failed","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"}