{"record":{"id":"f63826b906bc57aa","repo":"hyperledger/fabric","slug":"requested-to-send-for-channel-s-but-no-such-chan","errorCode":null,"errorMessage":"requested to Send for channel %s, but no such channel exists","messagePattern":"requested to Send for channel (.+?), but no such channel exists","errorType":"error_code","errorClass":null,"httpStatus":null,"severity":"error","filePath":"gossip/gossip/gossip_impl.go","lineNumber":643,"sourceCode":"// SendByCriteria sends a given message to all peers that match the given SendCriteria\nfunc (g *Node) SendByCriteria(msg *protoext.SignedGossipMessage, criteria SendCriteria) error {\n\tif criteria.MaxPeers == 0 {\n\t\treturn nil\n\t}\n\tif criteria.Timeout == 0 {\n\t\treturn errors.New(\"Timeout should be specified\")\n\t}\n\n\tif criteria.IsEligible == nil {\n\t\tcriteria.IsEligible = filter.SelectAllPolicy\n\t}\n\n\tmembership := g.disc.GetMembership()\n\n\tif len(criteria.Channel) > 0 {\n\t\tgc := g.chanState.getGossipChannelByChainID(criteria.Channel)\n\t\tif gc == nil {\n\t\t\treturn fmt.Errorf(\"requested to Send for channel %s, but no such channel exists\", criteria.Channel)\n\t\t}\n\t\tmembership = gc.GetPeers()\n\t}\n\n\tpeers2send := filter.SelectPeers(criteria.MaxPeers, membership, criteria.IsEligible)\n\tif len(peers2send) < criteria.MinAck {\n\t\treturn fmt.Errorf(\"requested to send to at least %d peers, but know only of %d suitable peers\", criteria.MinAck, len(peers2send))\n\t}\n\n\tresults := g.comm.SendWithAck(msg, criteria.Timeout, criteria.MinAck, peers2send...)\n\n\tfor _, res := range results {\n\t\tif res.Error() == \"\" {\n\t\t\tcontinue\n\t\t}\n\t\tg.logger.Warning(\"Failed sending to\", res.Endpoint, \"error:\", res.Error())\n\t}\n","sourceCodeStart":625,"sourceCodeEnd":661,"githubUrl":"https://github.com/hyperledger/fabric/blob/2736b63f8fd5932511d56fe68b7039d15977f7f6/gossip/gossip/gossip_impl.go#L625-L661","documentation":"SendByCriteria resolves the target channel via chanState.getGossipChannelByChainID when criteria.Channel is set. If no gossip channel was joined for that chain ID, membership cannot be scoped, so the send is rejected with this error rather than broadcasting blindly.","triggerScenarios":"Calling SendByCriteria with criteria.Channel set to a channel name the node never joined (JoinChan not called), a misspelled chain ID, or a channel the node left/stopped before the send.","commonSituations":"Sending messages to peers on a newly created channel before the local node's gossip service joined it; byte-slice channel names compared by exact bytes so typos or wrong encoding slip through; channel removed by config change while a sender still targets it.","solutions":["Call JoinChan (or ensure the peer actually joined) for the target channel before sending","Verify the exact channel ID bytes match the channel's name (channel is a []byte compared by value)","Check the peer's gossip membership/state to confirm the channel exists before issuing the send"],"exampleFix":"// before\ng.SendByCriteria(msg, SendCriteria{Channel: []byte(\"my-channel\"), Timeout: time.Second, MaxPeers: 2})\n\n// after\nif g.chanState.getGossipChannelByChainID([]byte(\"my-channel\")) == nil {\n    g.JoinChan(joinMsg, common.ChainID(\"my-channel\"))\n}\ng.SendByCriteria(msg, SendCriteria{Channel: []byte(\"my-channel\"), Timeout: time.Second, MaxPeers: 2})","handlingStrategy":"validation","validationCode":"// Confirm the channel exists before sending\nif gc := g.chanState.getGossipChannelByChainID(criteria.Channel); gc == nil {\n    return fmt.Errorf(\"cannot send: not joined to channel %s\", criteria.Channel)\n}\nerr := g.SendByCriteria(msg, criteria)","typeGuard":null,"tryCatchPattern":"if err := g.SendByCriteria(msg, criteria); err != nil && strings.Contains(err.Error(), \"no such channel exists\") {\n    logger.Warningf(\"skipping send, not a member of %s\", criteria.Channel)\n    return\n}","preventionTips":["Call JoinChan before any channel-scoped gossip sends","Compare channel IDs as exact byte slices; use common.ChainID to avoid typos","Log membership state when a channel-scoped send fails"],"tags":["gossip","hyperledger-fabric","channel"],"backgroundTag":"channel-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"}