{"record":{"id":"ed2ff07afc699c87","repo":"hyperledger/fabric","slug":"failed-obtaining-channel-state","errorCode":null,"errorMessage":"failed obtaining channel state","messagePattern":"failed obtaining channel state","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"core/endorser/plugin_endorser.go","lineNumber":131,"sourceCode":"\t}\n\n\tpluginInstance := pbc.pluginFactory.New()\n\tplugin, err := pbc.initPlugin(pluginInstance, channel)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tpbc.channels2Plugins[channel] = plugin\n\treturn plugin, nil\n}\n\nfunc (pbc *pluginsByChannel) initPlugin(plugin endorsement.Plugin, channel string) (endorsement.Plugin, error) {\n\tvar dependencies []endorsement.Dependency\n\tvar err error\n\t// If this is a channel endorsement, add the channel state as a dependency\n\tif channel != \"\" {\n\t\tquery, err := pbc.pe.NewQueryCreator(channel)\n\t\tif err != nil {\n\t\t\treturn nil, errors.Wrap(err, \"failed obtaining channel state\")\n\t\t}\n\t\tstore := pbc.pe.TransientStoreRetriever.StoreForChannel(channel)\n\t\tif store == nil {\n\t\t\treturn nil, errors.Errorf(\"transient store for channel %s was not initialized\", channel)\n\t\t}\n\t\tdependencies = append(dependencies, &ChannelState{QueryCreator: query, Store: store})\n\t}\n\t// Add the SigningIdentityFetcher as a dependency\n\tdependencies = append(dependencies, pbc.pe.SigningIdentityFetcher)\n\terr = plugin.Init(dependencies...)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treturn plugin, nil\n}\n\n// PluginEndorser endorsers proposal responses using plugins\ntype PluginEndorser struct {","sourceCodeStart":113,"sourceCodeEnd":149,"githubUrl":"https://github.com/hyperledger/fabric/blob/2736b63f8fd5932511d56fe68b7039d15977f7f6/core/endorser/plugin_endorser.go#L113-L149","documentation":"initPlugin fails while building the endorsement plugin's dependencies because NewQueryCreator for the channel returns an error. In practice this means the peer has no ledger for the given channel (see SupportImpl.NewQueryCreator), so the channel-state dependency for the plugin cannot be created.","triggerScenarios":"PluginEndorser.EndorseWithPlugin -> initPlugin with a non-empty channel whose ledger lookup via pe.NewQueryCreator(channel) fails — typically the channel name in the proposal is unknown to the peer or the ledger is not open yet.","commonSituations":"Proposal submitted to a peer that has not joined the channel; typo'd or mismatched channel ID in the proposal header; peer still joining/synchronizing the channel when a request arrives; chaincode installed but channel not joined.","solutions":["Join the peer to the channel (peer channel join) and wait for the ledger to open","Verify the channel ID in the proposal/SDK connection profile matches a channel the peer has joined (peer channel list)","Check peer logs for ledger-open errors during channel join","Retry after peer startup completes if the request raced channel initialization"],"exampleFix":"// before: invoking on peer that never joined the channel\ntargets: [peerWithoutChannel]\n// after: verify channel membership first\nconst channels = await newChannelQuery(peer);\nif (!channels.getChannels().some(c => c.getChannelId() === 'mychannel')) { await joinChannel(peer); }","handlingStrategy":"validation","validationCode":"const channels = await adminClient.queryChannels(peer);\nif (!channels.channels.some(c => c.channel_id === channelName)) {\n  throw new Error(`peer ${peer.name} has not joined ${channelName}`);\n}","typeGuard":null,"tryCatchPattern":"try {\n  return await initPlugin(name, channel);\n} catch (e) {\n  if (e.message.includes('failed obtaining channel state')) {\n    throw new Error(`peer not ready for channel ${channel}; join peer or retry after startup`, { cause: e });\n  }\n  throw e;\n}","preventionTips":["Only target peers returned by service discovery for the channel","Run 'peer channel list' after joining a peer before routing traffic","Gate client traffic behind peer readiness probes","Match channel IDs exactly between connection profiles and network"],"tags":["hyperledger-fabric","endorser","plugin","channel","ledger"],"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"}