hyperledger/fabric · error
could not get last config for channel %s
Error message
could not get last config for channel %s
What it means
DiscoverySupport.Config builds the channel's config result from the peer's current channel config. If GetCurrConfig(channel) returns nil — the service holds no last-config for that channel — it cannot produce a ConfigResult and returns this error.
Source
Thrown at discovery/support/config/support.go:57
// DiscoverySupport implements support that is used for service discovery
// that is related to configuration
type DiscoverySupport struct {
CurrentConfigGetter
}
// NewDiscoverySupport creates a new DiscoverySupport
func NewDiscoverySupport(getLastConfig CurrentConfigGetter) *DiscoverySupport {
return &DiscoverySupport{
CurrentConfigGetter: getLastConfig,
}
}
// Config returns the channel's configuration
func (s *DiscoverySupport) Config(channel string) (*discovery.ConfigResult, error) {
config := s.GetCurrConfig(channel)
if config == nil {
return nil, errors.Errorf("could not get last config for channel %s", channel)
}
if err := ValidateConfig(config); err != nil {
return nil, errors.WithMessage(err, "config is invalid")
}
res := &discovery.ConfigResult{
Msps: make(map[string]*msp.FabricMSPConfig),
Orderers: make(map[string]*discovery.Endpoints),
}
ordererGrp := config.ChannelGroup.Groups[channelconfig.OrdererGroupKey].Groups
appGrp := config.ChannelGroup.Groups[channelconfig.ApplicationGroupKey].Groups
var globalEndpoints []string
globalOrderers := config.ChannelGroup.Values[channelconfig.OrdererAddressesKey]
if globalOrderers != nil {
ordererAddressesConfig := &common.OrdererAddresses{}
if err := proto.Unmarshal(globalOrderers.Value, ordererAddressesConfig); err != nil {View on GitHub (pinned to 2736b63f8f)
Solutions
- Wait until the peer has committed the channel's latest config block, then retry the config query
- Verify the channel name and that the peer joined it (peer channel list)
- Check peer logs for ledger/config load failures that would leave GetCurrConfig nil
Defensive patterns
Strategy: retry
Validate before calling
// query after the peer reports the channel as active
status := getChannelStatus(peerEndpoint, channelID)
if status != "active" {
return fmt.Errorf("channel %s not active yet", channelID)
} Try / catch
var res *discovery.ConfigResult
err := retry.Do(func() error {
r, err := client.Send(ctx, req)
if err != nil && strings.Contains(err.Error(), "could not get last config") {
return retry.RetryableError(err) // config may still be loading
}
res = r
return err
}) Prevention
- Delay config queries until after the peer commits the channel config block
- Verify channel name and peer membership before querying
- Alert on peer ledger/config load failures
When it happens
Trigger: A discovery config query for a channel the peer hasn't joined or whose config hasn't been loaded into the config service; also hit in unit tests when the fake GetCurrConfig returns nil.
Common situations: Config query issued immediately after channel creation before the peer processes the config block; peer joined to a different channel than requested; name typo in the discovery request.
Related errors
- channel %s doesn't exist
- policy manager for channel %s doesn't exist
- failed unmarshalling orderer addresses
- failed computing orderer addresses
- error unmarshalling ConfigEnvelope
AI-assisted analysis of hyperledger/fabric@2736b63f8f (2026-09-04).
Data as JSON: /api/errors/33852010b9b2bb5a.
Report an issue: GitHub.