{"record":{"id":"e03dae82d42aa41f","repo":"hyperledger/fabric","slug":"failed-to-look-up-the-ledger-for-channel-s","errorCode":null,"errorMessage":"failed to look up the ledger for Channel %s","messagePattern":"failed to look up the ledger for Channel (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"core/endorser/support.go","lineNumber":83,"sourceCode":"\t}\n\treturn lgr.NewTxSimulator(txid)\n}\n\n// GetHistoryQueryExecutor gives handle to a history query executor for the\n// specified ledger\nfunc (s *SupportImpl) GetHistoryQueryExecutor(ledgername string) (ledger.HistoryQueryExecutor, error) {\n\tlgr := s.Peer.GetLedger(ledgername)\n\tif lgr == nil {\n\t\treturn nil, errors.Errorf(\"Channel does not exist: %s\", ledgername)\n\t}\n\treturn lgr.NewHistoryQueryExecutor()\n}\n\n// GetTransactionByID retrieves a transaction by id\nfunc (s *SupportImpl) GetTransactionByID(chid, txID string) (*pb.ProcessedTransaction, error) {\n\tlgr := s.Peer.GetLedger(chid)\n\tif lgr == nil {\n\t\treturn nil, errors.Errorf(\"failed to look up the ledger for Channel %s\", chid)\n\t}\n\ttx, err := lgr.GetTransactionByID(txID)\n\tif err != nil {\n\t\treturn nil, errors.WithMessage(err, \"GetTransactionByID failed\")\n\t}\n\treturn tx, nil\n}\n\n// GetLedgerHeight returns ledger height for given channelID\nfunc (s *SupportImpl) GetLedgerHeight(channelID string) (uint64, error) {\n\tlgr := s.Peer.GetLedger(channelID)\n\tif lgr == nil {\n\t\treturn 0, errors.Errorf(\"failed to look up the ledger for Channel %s\", channelID)\n\t}\n\n\tinfo, err := lgr.GetBlockchainInfo()\n\tif err != nil {\n\t\treturn 0, errors.Wrap(err, fmt.Sprintf(\"failed to obtain information for Channel %s\", channelID))","sourceCodeStart":65,"sourceCodeEnd":101,"githubUrl":"https://github.com/hyperledger/fabric/blob/2736b63f8fd5932511d56fe68b7039d15977f7f6/core/endorser/support.go#L65-L101","documentation":"GetTransactionByID could not resolve the channel to a ledger on this peer, so the transaction ID cannot be looked up. GetLedger(chid) returned nil; this is a channel-existence guard, distinct from the subsequent 'GetTransactionByID failed' wrap which indicates the tx itself was not found in an existing ledger.","triggerScenarios":"Support.GetTransactionByID(chid, txID) invoked (e.g. from the endorser validating duplicate txids) with a channel the peer does not have a ledger for.","commonSituations":"Duplicate-txid check during endorsement on a peer not joined to the proposal's channel; client querying transaction status against the wrong peer; channel name mismatch between SDK and network.","solutions":["Join the peer to the channel or route the request to a peer on that channel","Verify the channel ID used by the client matches the deployed channel","If the ledger exists but the tx is missing, look for the separate 'GetTransactionByID failed' wrap instead (tx genuinely not committed)","Check peer startup logs for channel open failures"],"exampleFix":null,"handlingStrategy":"validation","validationCode":"if (!await peerJoinedChannel(peer, chid)) throw new Error(`query tx ${txID} on a peer joined to ${chid}`);","typeGuard":null,"tryCatchPattern":"try {\n  return await getTransactionById(chid, txID);\n} catch (e) {\n  if (e.message.includes('failed to look up the ledger for Channel')) {\n    throw new Error(`peer has no ledger for ${chid}; wrong peer or channel`, { cause: e });\n  }\n  if (e.message.includes('GetTransactionByID failed')) {\n    throw new Error('transaction not found in ledger (may not be committed yet)', { cause: e });\n  }\n  throw e;\n}","preventionTips":["Distinguish channel-missing errors from txid-not-found errors in client handling","Route tx queries to peers on the tx's channel only","Re-check channel IDs after network reconfiguration","Wait for commit events before querying a transaction"],"tags":["hyperledger-fabric","endorser","channel","transaction"],"backgroundTag":"channel-not-joined","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"}