{"record":{"id":"ccde18192310195a","repo":"hyperledger/fabric","slug":"failed-to-find-ledger-for-channel-s","errorCode":null,"errorMessage":"failed to find ledger for channel: %s","messagePattern":"failed to find ledger for channel: (.+?)","errorType":"error_code","errorClass":null,"httpStatus":null,"severity":"error","filePath":"core/chaincode/handler.go","lineNumber":1386,"sourceCode":"\t\t)\n\t\treturn nil, errors.WithStack(err)\n\t}\n\n\t// Set up a new context for the called chaincode if on a different channel\n\t// We grab the called channel's ledger simulator to hold the new state\n\ttxParams := &ccprovider.TransactionParams{\n\t\tTxID:                 msg.Txid,\n\t\tChannelID:            targetInstance.ChannelID,\n\t\tSignedProp:           txContext.SignedProp,\n\t\tProposal:             txContext.Proposal,\n\t\tTXSimulator:          txContext.TXSimulator,\n\t\tHistoryQueryExecutor: txContext.HistoryQueryExecutor,\n\t}\n\n\tif targetInstance.ChannelID != txContext.ChannelID {\n\t\tlgr := h.LedgerGetter.GetLedger(targetInstance.ChannelID)\n\t\tif lgr == nil {\n\t\t\treturn nil, errors.Errorf(\"failed to find ledger for channel: %s\", targetInstance.ChannelID)\n\t\t}\n\n\t\tsim, err := lgr.NewTxSimulator(msg.Txid)\n\t\tif err != nil {\n\t\t\treturn nil, errors.WithStack(err)\n\t\t}\n\t\tdefer sim.Done()\n\n\t\thqe, err := lgr.NewHistoryQueryExecutor()\n\t\tif err != nil {\n\t\t\treturn nil, errors.WithStack(err)\n\t\t}\n\n\t\ttxParams.TXSimulator = sim\n\t\ttxParams.HistoryQueryExecutor = hqe\n\t}\n\n\t// Execute the chaincode... this CANNOT be an init at least for now","sourceCodeStart":1368,"sourceCodeEnd":1404,"githubUrl":"https://github.com/hyperledger/fabric/blob/2736b63f8fd5932511d56fe68b7039d15977f7f6/core/chaincode/handler.go#L1368-L1404","documentation":"Returned by the peer's chaincode handler (executeChaincode) when a chaincode-to-chaincode invocation targets a channel whose ledger cannot be found in the peer's LedgerGetter. The peer cannot obtain a query executor or transaction simulator for the target channel, so the cross-channel call is aborted. This guards against invoking chaincode on a channel this peer has not joined.","triggerScenarios":"A chaincode invokes another chaincode via InvokeChaincode while specifying a ChannelID (targetInstance.ChannelID) that differs from the caller's channel, and GetLedger(targetInstance.ChannelID) returns nil — i.e., the peer is not joined to that channel or the ledger is not open.","commonSituations":"Cross-channel InvokeChaincode calls to a channel the peer hasn't joined; typo'd channel ID in the invocation; channel ID omitted or hardcoded in chaincode config; peer recently removed from the channel while the caller still references it.","solutions":["Verify the peer is joined to the target channel (peer channel list) and join it if missing.","Check the ChannelID passed to InvokeChaincode for typos or wrong casing.","Ensure cross-chaincode invocations only target channels shared by the endorsing peers of the original transaction.","If using fabric-peer per-org topology, route the call through an org whose peers are on both channels."],"exampleFix":"// before (chaincode, Go)\nresp := ctx.GetStub().InvokeChaincode(ccName, args, \"wrongchannel\")\n\n// after\nresp := ctx.GetStub().InvokeChaincode(ccName, args, \"mychannel\") // channel the endorsing peers have joined","handlingStrategy":"validation","validationCode":"// before cross-chaincode invoke\nconst targetChannel = \"otherchannel\"\n// verify via peer CLI before deploying:\n//   peer channel list   -> must include targetChannel on every endorsing peer\nif targetChannel == stub.GetChannelId() {\n    return shim.Error(\"use direct call, not cross-channel invoke\")\n}","typeGuard":"func channelKnown(channels []string, target string) bool {\n    for _, c := range channels { if c == target { return true } }\n    return false\n}","tryCatchPattern":null,"preventionTips":["Keep an inventory of channels each peer/org serves and only cross-invoke common channels.","Centralize channel name constants; never hardcode channel IDs in chaincode.","Test cross-channel invocations in CI with the real peer topology."],"tags":["hyperledger-fabric","chaincode","ledger","cross-channel"],"backgroundTag":"ledger-not-found-for-channel","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"}