{"record":{"id":"bbeba8aedaf6aaeb","repo":"hyperledger/fabric","slug":"expected-chaincode-s-but-got-endorsement-descript","errorCode":null,"errorMessage":"expected chaincode %s but got endorsement descriptor for %s","messagePattern":"expected chaincode (.+?) but got endorsement descriptor for (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"discovery/client/client.go","lineNumber":482,"sourceCode":"\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(),\n\t\t}\n\n\t\tdescriptor, err := resp.createEndorsementDescriptor(desc, channel)\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t\tresp[key] = descriptor\n\t}\n\n\treturn nil\n}\n\nfunc (resp response) createEndorsementDescriptor(desc *discovery.EndorsementDescriptor, channel string) (*endorsementDescriptor, error) {","sourceCodeStart":464,"sourceCodeEnd":500,"githubUrl":"https://github.com/hyperledger/fabric/blob/2736b63f8fd5932511d56fe68b7039d15977f7f6/discovery/client/client.go#L464-L500","documentation":"mapEndorsersOfChannel matches each returned endorsement descriptor positionally with the requested InvocationChain: invocationChain[i][0].Name must equal desc.Chaincode. If the server returned a descriptor for a different chaincode than expected at index i, this error reports both names. It signals the client's requested chaincode order and the server's descriptor order disagree, usually because the wrong chaincode name was requested or discovery data is stale.","triggerScenarios":"A chaincode query where the descriptor at position i is for a chaincode other than invocationChain[i][0].Name — e.g. typos in the chaincode name, querying a different channel that has a chaincode with the same position but different name, or server response ordering differing from the request.","commonSituations":"Misspelled chaincode name in ForChannel call; referencing the default vs upgraded chaincode name; a channel where a different chaincode occupies the slot because the requested one isn't installed; client code caching invocation chains from another channel.","solutions":["Compare the two chaincode names in the error — fix the name passed in the InvocationChain/chaincode interest","Ensure the chaincode interest matches exactly what is installed and committed on the channel","Make sure you query the intended channel (channel name typo)","Re-run discovery after chaincode lifecycle operations finish (install/commit)","Clear any cached invocation chain / chaincode interest built from a previous channel or version"],"exampleFix":"// before\nchaincode := InvocationChain{{Name: \"myCC\"}} // typo\n// after\nchaincode := InvocationChain{{Name: \"mycc\"}} // matches installed chaincode name","handlingStrategy":"validation","validationCode":"// Validate chaincode names against committed definitions\nfor _, chain := range invocationChains {\n\tif !isChaincodeCommitted(channel, chain[0].Name) {\n\t\treturn fmt.Errorf(\"chaincode %q not committed on %s\", chain[0].Name, channel)\n\t}\n}","typeGuard":null,"tryCatchPattern":"if err != nil && strings.Contains(err.Error(), \"but got endorsement descriptor for\") {\n\tlog.Printf(\"chaincode name mismatch: %v — check requested name vs installed name\", err)\n\treturn err\n}","preventionTips":["Copy chaincode names from lifecycle output, never by hand","Distinguish capitalization exactly (Go chaincode names are case-sensitive)","Query the correct channel for the intended invocation chain","Invalidate cached invocation chains after chaincode upgrades"],"tags":["hyperledger-fabric","discovery-service","chaincode","name-mismatch"],"backgroundTag":"chaincode-name-mismatch","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"}