{"record":{"id":"daec130a8de86da9","repo":"hyperledger/fabric","slug":"channel-does-not-exist-s-daec13","errorCode":null,"errorMessage":"channel does not exist: %s","messagePattern":"channel does not exist: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/pkg/gateway/ledger/peeradapter.go","lineNumber":40,"sourceCode":"\tGetBlockchainInfo() (*common.BlockchainInfo, error)\n\tGetBlocksIterator(startBlockNumber uint64) (ledger.ResultsIterator, error)\n\tGetTxValidationCodeByTxID(txID string) (peerproto.TxValidationCode, uint64, error)\n}\n\n// Provider presents a small piece of the Peer in a form that can be easily used (and mocked) by gateway implementation.\ntype Provider interface {\n\tLedger(channelName string) (Ledger, error)\n}\n\n// PeerAdapter presents a peer as a LedgerProvider to aid mocking.\ntype PeerAdapter struct {\n\tPeer *peer.Peer\n}\n\nfunc (adapter *PeerAdapter) Ledger(channelName string) (Ledger, error) {\n\tchannel := adapter.Peer.Channel(channelName)\n\tif channel == nil {\n\t\treturn nil, errors.Errorf(\"channel does not exist: %s\", channelName)\n\t}\n\n\treturn channel.Ledger(), nil\n}\n","sourceCodeStart":22,"sourceCodeEnd":45,"githubUrl":"https://github.com/hyperledger/fabric/blob/2736b63f8fd5932511d56fe68b7039d15977f7f6/internal/pkg/gateway/ledger/peeradapter.go#L22-L45","documentation":"PeerAdapter.Ledger resolves the named channel on the embedded peer and, if the peer has no such channel, returns errors.Errorf(\"channel does not exist: %s\"). The gateway uses this adapter to fetch a ledger for chaincode events; a missing channel means the peer has not joined that channel, so no ledger exists for it.","triggerScenarios":"Requesting chaincode events (or any gateway ledger lookup) for a channelName the peer has not joined, or with a misspelled/nonexistent channel name; calling Ledger() before the peer finishes joining the channel.","commonSituations":"Typo in channel name in client config; client targets a peer that isn't a member of the channel (multi-org deployments); channel created but peer not yet joined; stale configuration after channel rename or peer re-join.","solutions":["Verify the channel name spelling against `peer channel list` on the target peer","Join the peer to the channel (peer channel join) before requesting its ledger/events","Target a gateway/peer that is actually a member of the channel","Wait for channel join to complete and the ledger to initialize before subscribing to events"],"exampleFix":"// before\ngateway.Evaluate(ctx, \"wrong-channel\", ...)  // peer not joined\n// after\nchannels := peer.ChannelList() // ensure \"mychannel\" present\ngateway.Evaluate(ctx, \"mychannel\", ...)","handlingStrategy":"validation","validationCode":"func ensureChannelJoined(peer *peer.Peer, channel string) error {\n    if peer.Channel(channel) == nil {\n        return fmt.Errorf(\"peer %s has not joined channel %q; join it or target another peer\", peer, channel)\n    }\n    return nil\n}","typeGuard":"func channelExists(adapter *ledger.PeerAdapter, name string) bool {\n    return adapter != nil && adapter.Peer != nil && adapter.Peer.Channel(name) != nil\n}","tryCatchPattern":"ledger, err := adapter.Ledger(channelName)\nif err != nil {\n    if strings.HasPrefix(err.Error(), \"channel does not exist\") {\n        return fmt.Errorf(\"check channel name and peer membership: %w\", err)\n    }\n    return err\n}","preventionTips":["Confirm channel membership with `peer channel list` before targeting a peer","Centralize channel name constants to avoid typos in client configs","After channel creation/join, wait for ledger initialization before event subscription"],"tags":["fabric","gateway","ledger","channel","configuration"],"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"}