{"record":{"id":"b40cec982179d721","repo":"hyperledger/fabric","slug":"no-metadata-was-found-for-chaincode-s-in-channel","errorCode":null,"errorMessage":"No metadata was found for chaincode %s in channel %s","messagePattern":"No metadata was found for chaincode (.+?) in channel (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"discovery/endorsement/endorsement.go","lineNumber":348,"sourceCode":"\tidentityInfoByID map[string]api.PeerIdentityInfo\n\tevaluator        principalEvaluator\n}\n\n// metadataAndColFilter holds metadata and member filters\ntype metadataAndColFilter struct {\n\tmd                 []*chaincode.Metadata\n\tisMemberAuthorized memberFilter\n}\n\nfunc loadMetadataAndFilters(ctx metadataAndFilterContext) (*metadataAndColFilter, error) {\n\tsessionLogger := logger.With(\"channel\", string(ctx.chainID))\n\tvar metadata []*chaincode.Metadata\n\tvar filters []identityFilter\n\n\tfor _, chaincode := range ctx.interest.Chaincodes {\n\t\tccMD := ctx.fetch.Metadata(string(ctx.chainID), chaincode.Name, chaincode.CollectionNames...)\n\t\tif ccMD == nil {\n\t\t\treturn nil, errors.Errorf(\"No metadata was found for chaincode %s in channel %s\", chaincode.Name, string(ctx.chainID))\n\t\t}\n\t\tmetadata = append(metadata, ccMD)\n\t\tif len(chaincode.CollectionNames) == 0 {\n\t\t\tsessionLogger.Debugf(\"No collections for %s, skipping\", chaincode.Name)\n\t\t\tcontinue\n\t\t}\n\t\tif chaincode.NoPrivateReads {\n\t\t\tsessionLogger.Debugf(\"No private reads, skipping\")\n\t\t\tcontinue\n\t\t}\n\t\tprincipalSetByCollections, err := principalsFromCollectionConfig(ccMD.CollectionsConfig)\n\t\tif err != nil {\n\t\t\tsessionLogger.Warningf(\"Failed initializing collection filter for chaincode %s: %v\", chaincode.Name, err)\n\t\t\treturn nil, errors.WithStack(err)\n\t\t}\n\t\tfilter, err := principalSetByCollections.toIdentityFilter(string(ctx.chainID), ctx.evaluator, chaincode)\n\t\tif err != nil {\n\t\t\tsessionLogger.Warningf(\"Failed computing collection principal sets for chaincode %s due to %v\", chaincode.Name, err)","sourceCodeStart":330,"sourceCodeEnd":366,"githubUrl":"https://github.com/hyperledger/fabric/blob/2736b63f8fd5932511d56fe68b7039d15977f7f6/discovery/endorsement/endorsement.go#L330-L366","documentation":"Thrown by loadMetadataAndFilters when the discovery service's chaincode metadata fetcher returns nil for a chaincode on the given channel, i.e. the peer serving discovery has no metadata (installed/committed chaincode or collection definitions) for it. Without metadata, discovery cannot validate collections or filter peers, so PeersForEndorsement fails with this message naming the chaincode and channel.","triggerScenarios":"PeersForEndorsement (or peersByCriteria) with a ChaincodeInterest referencing a chaincode whose metadata lookup on the responding peer returns nil — chaincode not installed on that peer, not committed on that channel, unknown collection names, or stale gossip/lifecycle state.","commonSituations":"Querying a channel where the chaincode was never committed; peer still syncing chaincode definitions after join; requesting collections not present in the committed collection config; mixed v1/v2 lifecycle networks where _lifecycle lacks the metadata.","solutions":["Confirm the chaincode is committed on the target channel: peer lifecycle chaincode querycommitted --channelID <ch>","Ensure the discovery request targets a peer that has the chaincode installed and committed","Verify collection names in the interest exist in the committed collection configuration","Retry after peer gossip/lifecycle sync completes; check peer logs for lifecycle errors"],"exampleFix":"// before\ninterest := interestWith(\"mycc\", channel=\"yourchannel\") // cc not on this channel\n// after\ninterest := interestWith(\"mycc\", channel=\"mychannel\") // committed channel","handlingStrategy":"validation","validationCode":"md, _ := lc.QueryInstalled(ctx) // and querycommitted per channel\nif !containsCommitted(md, ccName, channel) {\n  return fmt.Errorf(\"no metadata for %s on %s\", ccName, channel)\n}","typeGuard":"func metadataExists(ccName, channel string, committed []lifecycle.ChaincodeDefinition) bool {\n  for _, c := range committed { if c.Name == ccName { return true } }\n  return false\n}","tryCatchPattern":"peers, err := client.PeersForEndorsement(ctx, interest)\nif err != nil && strings.Contains(err.Error(), \"No metadata was found\") {\n  // confirm install/commit state on the responding peer, then retry\n}","preventionTips":["Discover only against peers with the chaincode installed and committed","Validate collection names against the committed collection config","Allow peer gossip/lifecycle sync time after joining or committing"],"tags":["fabric","discovery","chaincode-metadata","lifecycle"],"backgroundTag":"chaincode-not-found","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"}