hyperledger/fabric · error
failed obtaining channel state
Error message
failed obtaining channel state
What it means
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.
Source
Thrown at core/endorser/plugin_endorser.go:131
}
pluginInstance := pbc.pluginFactory.New()
plugin, err := pbc.initPlugin(pluginInstance, channel)
if err != nil {
return nil, err
}
pbc.channels2Plugins[channel] = plugin
return plugin, nil
}
func (pbc *pluginsByChannel) initPlugin(plugin endorsement.Plugin, channel string) (endorsement.Plugin, error) {
var dependencies []endorsement.Dependency
var err error
// If this is a channel endorsement, add the channel state as a dependency
if channel != "" {
query, err := pbc.pe.NewQueryCreator(channel)
if err != nil {
return nil, errors.Wrap(err, "failed obtaining channel state")
}
store := pbc.pe.TransientStoreRetriever.StoreForChannel(channel)
if store == nil {
return nil, errors.Errorf("transient store for channel %s was not initialized", channel)
}
dependencies = append(dependencies, &ChannelState{QueryCreator: query, Store: store})
}
// Add the SigningIdentityFetcher as a dependency
dependencies = append(dependencies, pbc.pe.SigningIdentityFetcher)
err = plugin.Init(dependencies...)
if err != nil {
return nil, err
}
return plugin, nil
}
// PluginEndorser endorsers proposal responses using plugins
type PluginEndorser struct {View on GitHub (pinned to 2736b63f8f)
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
Example fix
// before: invoking on peer that never joined the channel
targets: [peerWithoutChannel]
// after: verify channel membership first
const channels = await newChannelQuery(peer);
if (!channels.getChannels().some(c => c.getChannelId() === 'mychannel')) { await joinChannel(peer); } Defensive patterns
Strategy: validation
Validate before calling
const channels = await adminClient.queryChannels(peer);
if (!channels.channels.some(c => c.channel_id === channelName)) {
throw new Error(`peer ${peer.name} has not joined ${channelName}`);
} Try / catch
try {
return await initPlugin(name, channel);
} catch (e) {
if (e.message.includes('failed obtaining channel state')) {
throw new Error(`peer not ready for channel ${channel}; join peer or retry after startup`, { cause: e });
}
throw e;
} Prevention
- 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
When it happens
Trigger: 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.
Common situations: 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.
Related errors
- transient store for channel %s was not initialized
- channel %s doesn't exist
- Channel does not exist: %s
- plugin with name %s wasn't found
- failed to look up the ledger for Channel %s
AI-assisted analysis of hyperledger/fabric@2736b63f8f (2026-09-04).
Data as JSON: /api/errors/ed2ff07afc699c87.
Report an issue: GitHub.