hyperledger/fabric · error
No metadata was found for chaincode %s in channel %s
Error message
No metadata was found for chaincode %s in channel %s
What it means
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.
Source
Thrown at discovery/endorsement/endorsement.go:348
identityInfoByID map[string]api.PeerIdentityInfo
evaluator principalEvaluator
}
// metadataAndColFilter holds metadata and member filters
type metadataAndColFilter struct {
md []*chaincode.Metadata
isMemberAuthorized memberFilter
}
func loadMetadataAndFilters(ctx metadataAndFilterContext) (*metadataAndColFilter, error) {
sessionLogger := logger.With("channel", string(ctx.chainID))
var metadata []*chaincode.Metadata
var filters []identityFilter
for _, chaincode := range ctx.interest.Chaincodes {
ccMD := ctx.fetch.Metadata(string(ctx.chainID), chaincode.Name, chaincode.CollectionNames...)
if ccMD == nil {
return nil, errors.Errorf("No metadata was found for chaincode %s in channel %s", chaincode.Name, string(ctx.chainID))
}
metadata = append(metadata, ccMD)
if len(chaincode.CollectionNames) == 0 {
sessionLogger.Debugf("No collections for %s, skipping", chaincode.Name)
continue
}
if chaincode.NoPrivateReads {
sessionLogger.Debugf("No private reads, skipping")
continue
}
principalSetByCollections, err := principalsFromCollectionConfig(ccMD.CollectionsConfig)
if err != nil {
sessionLogger.Warningf("Failed initializing collection filter for chaincode %s: %v", chaincode.Name, err)
return nil, errors.WithStack(err)
}
filter, err := principalSetByCollections.toIdentityFilter(string(ctx.chainID), ctx.evaluator, chaincode)
if err != nil {
sessionLogger.Warningf("Failed computing collection principal sets for chaincode %s due to %v", chaincode.Name, err)View on GitHub (pinned to 2736b63f8f)
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
Example fix
// before
interest := interestWith("mycc", channel="yourchannel") // cc not on this channel
// after
interest := interestWith("mycc", channel="mychannel") // committed channel Defensive patterns
Strategy: validation
Validate before calling
md, _ := lc.QueryInstalled(ctx) // and querycommitted per channel
if !containsCommitted(md, ccName, channel) {
return fmt.Errorf("no metadata for %s on %s", ccName, channel)
} Type guard
func metadataExists(ccName, channel string, committed []lifecycle.ChaincodeDefinition) bool {
for _, c := range committed { if c.Name == ccName { return true } }
return false
} Try / catch
peers, err := client.PeersForEndorsement(ctx, interest)
if err != nil && strings.Contains(err.Error(), "No metadata was found") {
// confirm install/commit state on the responding peer, then retry
} Prevention
- 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
When it happens
Trigger: 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.
Common situations: 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.
Related errors
- query iterator not found
- application config does not exist for channel '%s'
- unknown chaincode '%s' for channel '%s'
- could not find chaincode with package id '%s'
- requested sequence is 0, but first definable sequence number
AI-assisted analysis of hyperledger/fabric@2736b63f8f (2026-09-04).
Data as JSON: /api/errors/b40cec982179d721.
Report an issue: GitHub.